mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Can change owner of enterprises from index page
This commit is contained in:
@@ -11,11 +11,12 @@
|
||||
%table#listing_enterprises.index
|
||||
%colgroup
|
||||
%col{style: "width: 25%;"}/
|
||||
%col{style: "width: 10%;"}/
|
||||
%col{style: "width: 15%;"}/
|
||||
%col{style: "width: 5%;"}/
|
||||
- if spree_current_user.admin?
|
||||
%col{style: "width: 10%;"}/
|
||||
%col{style: "width: 20%;"}/
|
||||
%col{style: "width: 12%;"}/
|
||||
%col{style: "width: 18%;"}/
|
||||
%col{style: "width: 25%;"}/
|
||||
%thead
|
||||
%tr{"data-hook" => "enterprises_header"}
|
||||
%th Name
|
||||
@@ -23,6 +24,7 @@
|
||||
%th Visible?
|
||||
- if spree_current_user.admin?
|
||||
%th Type
|
||||
%th Owner
|
||||
%th
|
||||
%tbody
|
||||
= f.fields_for :collection do |enterprise_form|
|
||||
@@ -38,6 +40,7 @@
|
||||
%td= enterprise_form.check_box :visible
|
||||
- if spree_current_user.admin?
|
||||
%td= enterprise_form.select :type, Enterprise::TYPES, {}, class: 'select2 fullwidth'
|
||||
%td= enterprise_form.select :owner_id, enterprise.users.map{ |e| [ e.email, e.id ] }, {}, class: "select2 fullwidth"
|
||||
%td{"data-hook" => "admin_users_index_row_actions"}
|
||||
= render 'actions', enterprise: enterprise
|
||||
- if @enterprises.empty?
|
||||
|
||||
@@ -38,6 +38,9 @@ feature %q{
|
||||
scenario "editing enterprises in bulk" do
|
||||
s = create(:supplier_enterprise)
|
||||
d = create(:distributor_enterprise, type: 'profile')
|
||||
d_manager = create_enterprise_user
|
||||
d_manager.enterprise_roles.build(enterprise: d).save
|
||||
expect(d.owner).to_not eq d_manager
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Enterprises'
|
||||
@@ -46,12 +49,14 @@ feature %q{
|
||||
expect(page).to have_checked_field "enterprise_set_collection_attributes_0_visible"
|
||||
uncheck "enterprise_set_collection_attributes_0_visible"
|
||||
select 'full', from: "enterprise_set_collection_attributes_0_type"
|
||||
select d_manager.email, from: 'enterprise_set_collection_attributes_0_owner_id'
|
||||
end
|
||||
click_button "Update"
|
||||
flash_message.should == 'Enterprises updated successfully'
|
||||
distributor = Enterprise.find(d.id)
|
||||
expect(distributor.visible).to eq false
|
||||
expect(distributor.type).to eq 'full'
|
||||
expect(distributor.owner).to eq d_manager
|
||||
end
|
||||
|
||||
scenario "viewing an enterprise" do
|
||||
|
||||
Reference in New Issue
Block a user