diff --git a/app/views/admin/enterprise_groups/_form.html.haml b/app/views/admin/enterprise_groups/_form.html.haml new file mode 100644 index 0000000000..b41a68d4a5 --- /dev/null +++ b/app/views/admin/enterprise_groups/_form.html.haml @@ -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} diff --git a/app/views/admin/enterprise_groups/index.html.haml b/app/views/admin/enterprise_groups/index.html.haml index 2fb4e235dc..70b838fab0 100644 --- a/app/views/admin/enterprise_groups/index.html.haml +++ b/app/views/admin/enterprise_groups/index.html.haml @@ -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 diff --git a/app/views/admin/enterprise_groups/new.html.haml b/app/views/admin/enterprise_groups/new.html.haml new file mode 100644 index 0000000000..f899eaa380 --- /dev/null +++ b/app/views/admin/enterprise_groups/new.html.haml @@ -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' diff --git a/spec/features/admin/enterprise_groups_spec.rb b/spec/features/admin/enterprise_groups_spec.rb index eb8a7494c9..4407ece33e 100644 --- a/spec/features/admin/enterprise_groups_spec.rb +++ b/spec/features/admin/enterprise_groups_spec.rb @@ -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