Create new enterprise group

This commit is contained in:
Rohan Mitchell
2013-10-24 14:33:07 +11:00
parent a6fa73ec13
commit be7e76920d
4 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
= f.field_container :name do
= f.label :name
%br/
= f.text_field :name
= f.field_container :on_front_page do
= f.label :on_front_page, 'On front page?'
%br/
= f.check_box :on_front_page
= f.field_container :enterprise_ids do
= f.label :enterprise_ids, 'Enterprises'
%br/
= f.collection_select :enterprise_ids, Enterprise.all, :id, :name, {}, {class: "select2 fullwidth", multiple: true}

View File

@@ -1,3 +1,9 @@
.toolbar{'data-hook' => "toolbar"}
%ul.actions
%li
= button_link_to "New Enterprise Group", main_app.new_admin_enterprise_group_path, :icon => 'add', :id => 'admin_new_enterprise_group_link'
%br.clear/
%h1 Enterprise Groups
%table.index#listing_enterprise_groups

View File

@@ -0,0 +1,5 @@
= render :partial => 'spree/shared/error_messages', :locals => { :target => @enterprise }
= form_for [main_app, :admin, @enterprise_group] do |f|
= render :partial => 'form', :locals => { :f => f }
= render :partial => 'spree/admin/shared/new_resource_links'

View File

@@ -23,4 +23,31 @@ feature %q{
page.should have_selector 'td', text: e.name
end
scenario "creating a new enterprise group" do
e1 = create(:enterprise)
e2 = create(:enterprise)
e3 = create(:enterprise)
click_link 'Configuration'
click_link 'Enterprise Groups'
click_link 'New Enterprise Group'
fill_in 'enterprise_group_name', with: 'EGEGEG'
check 'enterprise_group_on_front_page'
select e1.name, from: 'enterprise_group_enterprise_ids'
select e2.name, from: 'enterprise_group_enterprise_ids'
click_button 'Create'
page.should have_content 'Enterprise group "EGEGEG" has been successfully created!'
eg = EnterpriseGroup.last
eg.name.should == 'EGEGEG'
eg.on_front_page.should be_true
eg.enterprises.sort.should == [e1, e2].sort
end
context "as an enterprise user" do
xit "should show me only enterprises I manage when creating a new enterprise group"
end
end