mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-22 05:18:51 +00:00
Create new enterprise group
This commit is contained in:
14
app/views/admin/enterprise_groups/_form.html.haml
Normal file
14
app/views/admin/enterprise_groups/_form.html.haml
Normal 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}
|
||||
@@ -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
|
||||
|
||||
5
app/views/admin/enterprise_groups/new.html.haml
Normal file
5
app/views/admin/enterprise_groups/new.html.haml
Normal 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'
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user