BPUR: can update supplier

This commit is contained in:
Rob H
2013-05-16 08:33:54 +05:30
committed by Rohan Mitchell
parent 1e64dab9f7
commit 344a084494
3 changed files with 18 additions and 2 deletions

View File

@@ -16,10 +16,13 @@
%thead
%tr
%th Name
%th Supplier
%tbody{ 'ng-repeat' => 'product in products | filter:query' }
%tr
%td
%input.product_name{ 'ng-model' => "product.name", :name => 'product_name', :type => 'text' }
%input{ 'ng-model' => "product.name", :name => 'product_name', :type => 'text' }
%td
%select.select2{ :name => 'supplier_id', 'ng-model' => 'product.supplier_id', 'ng-options' => 's.id as s.name for s in suppliers' }
%input{:type => 'button', :value => 'Update', 'ng-click' => 'prepareProductsForSubmit()'}
%span{ id: "update-status-message", 'ng-style' => 'updateStatusMessage.style' }
{{ updateStatusMessage.text }}

View File

@@ -1,4 +1,5 @@
r.list_of :products, @collection do
r.element :id
r.element :name
r.element :supplier_id
end

View File

@@ -17,13 +17,19 @@ feature %q{
end
scenario "listing products" do
s1 = FactoryGirl.create(:supplier_enterprise)
s2 = FactoryGirl.create(:supplier_enterprise)
s3 = FactoryGirl.create(:supplier_enterprise)
p = FactoryGirl.create(:product)
p.supplier = s1;
login_to_admin_section
click_link 'Products'
click_link 'Bulk Product Edit'
page.should have_field "product_name", with: p.name
page.should have_select "supplier_id", with_options: [s1.name,s2.name,s3.name], selected: s1.name
end
scenario "create a new product" do
@@ -53,20 +59,26 @@ feature %q{
scenario "updating a product" do
p = FactoryGirl.create(:product)
s1 = FactoryGirl.create(:supplier_enterprise)
s2 = FactoryGirl.create(:supplier_enterprise)
p = FactoryGirl.create(:product)
p.supplier = s1
login_to_admin_section
click_link 'Products'
click_link 'Bulk Product Edit'
page.should have_field "product_name", with: p.name
page.should have_select "supplier_id", selected: s1.name
fill_in "product_name", with: "Big Bag Of Potatoes"
select(s2.name, :from => 'supplier_id')
click_button 'Update'
page.find("span#update-status-message").should have_content "Update complete"
click_link 'Bulk Product Edit'
page.should have_field "product_name", with: "Big Bag Of Potatoes"
page.should have_select "supplier_id", selected: s2.name
end
end