mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Admin can update producer properties
This commit is contained in:
@@ -19,7 +19,9 @@ class Enterprise < ActiveRecord::Base
|
||||
|
||||
delegate :latitude, :longitude, :city, :state_name, :to => :address
|
||||
|
||||
accepts_nested_attributes_for :address, :producer_properties
|
||||
accepts_nested_attributes_for :address
|
||||
accepts_nested_attributes_for :producer_properties, allow_destroy: true, reject_if: lambda { |pp| pp[:property_name].blank? }
|
||||
|
||||
has_attached_file :logo, :styles => { :medium => "300x300>", :thumb => "100x100>" }
|
||||
has_attached_file :promo_image, :styles => { :large => "1200x260#", :thumb => "100x100>" }
|
||||
|
||||
|
||||
@@ -183,6 +183,29 @@ feature %q{
|
||||
s.producer_properties.first.property.presentation.should == "Certified Organic"
|
||||
s.producer_properties.first.value.should == "NASAA 12345"
|
||||
end
|
||||
|
||||
it "updates producer properties" do
|
||||
# Given a producer enterprise with a property
|
||||
s = create(:supplier_enterprise)
|
||||
s.producer_properties.create! property_name: 'Certified Organic', value: 'NASAA 12345'
|
||||
|
||||
# When I go to its properties page
|
||||
login_to_admin_section
|
||||
visit main_app.admin_enterprise_producer_properties_path(s)
|
||||
|
||||
# And I update the property
|
||||
fill_in 'enterprise_producer_properties_attributes_0_property_name', with: "Biodynamic"
|
||||
fill_in 'enterprise_producer_properties_attributes_0_value', with: "Shininess"
|
||||
click_button 'Update'
|
||||
|
||||
# Then I should be returned to the producer properties page
|
||||
page.should have_selector 'h1.page-title', text: "Producer Properties"
|
||||
|
||||
# And the property should be updated
|
||||
s.producer_properties(true).count.should == 1
|
||||
s.producer_properties.first.property.presentation.should == "Biodynamic"
|
||||
s.producer_properties.first.value.should == "Shininess"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user