Commit ac4a3164 by vulehuan

change some url when move some card functions to other actions

parent e8c1157b
......@@ -24,12 +24,10 @@ end
describe "CardPages" do
subject { page }
before(:all) do
before(:each) do
@product_category = FactoryGirl.create(:product_category)
@user = FactoryGirl.create(:user)
end
before(:each) do
5.times { FactoryGirl.create(:product, product_category_id: @product_category.id, user_id: @user.id) }
Product.all.each do |product|
visit product_path(product)
......@@ -37,13 +35,10 @@ describe "CardPages" do
end
end
after(:all) do
User.delete_all
ProductCategory.delete_all
end
after(:each) do
Product.delete_all
User.delete_all
ProductCategory.delete_all
end
describe "step 1" do
......@@ -51,7 +46,7 @@ describe "CardPages" do
describe "with invalid information" do
describe "when product not exist" do
before do
visit cards_path(card_action: 'update', product_id: 0, quantity: "abc")
visit url_for(controller: 'cards', action: 'update', product_id: 0, quantity: "abc")
end
it { should have_selector('.alert.alert-error', text: 'Invalid') }
......@@ -60,7 +55,7 @@ describe "CardPages" do
describe "when quantity is not a number" do
before do
product = Product.first
visit cards_path(card_action: 'update', product_id: product.id , quantity: "abc")
visit url_for(controller: 'cards', action: 'update', product_id: product.id , quantity: "abc")
end
it { should have_selector('.alert.alert-error', text: 'Invalid') }
......@@ -69,7 +64,7 @@ describe "CardPages" do
describe "when quantity < 0" do
before do
product = Product.first
visit cards_path(card_action: 'update', product_id: product.id , quantity: -1)
visit url_for(controller: 'cards', action: 'update', product_id: product.id , quantity: -1)
end
it { should have_selector('.alert.alert-error', text: 'Invalid') }
......@@ -78,7 +73,7 @@ describe "CardPages" do
describe "when quantity = 0" do
before do
product = Product.first
visit cards_path(card_action: 'update', product_id: product.id , quantity: 0)
visit url_for(controller: 'cards', action: 'update', product_id: product.id , quantity: 0)
end
it { should have_selector('.alert.alert-error', text: 'Invalid') }
......@@ -91,7 +86,7 @@ describe "CardPages" do
let(:product) { Product.first }
before do
visit cards_path(card_action: 'update', product_id: product.id , quantity: amount)
visit url_for(controller: 'cards', action: 'update', product_id: product.id , quantity: amount)
end
it do
......@@ -116,7 +111,7 @@ describe "CardPages" do
describe "when product not exist" do
before do
visit cards_path(card_action: 'update', product_id: 0)
visit url_for(controller: 'cards', action: 'update', product_id: 0)
end
it { should have_selector('.alert.alert-error', text: 'Invalid') }
......@@ -126,7 +121,7 @@ describe "CardPages" do
let(:product_not_in_card) { FactoryGirl.create(:product, product_category_id: @product_category.id, user_id: @user.id) }
before do
visit cards_path(card_action: 'remove', product_id: product_not_in_card.id)
visit url_for(controller: 'cards', action: 'remove', product_id: product_not_in_card.id)
end
it { should have_selector('.alert.alert-error', text: 'Invalid') }
......@@ -140,7 +135,7 @@ describe "CardPages" do
total = 0
before do
visit cards_path(card_action: 'remove', product_id: product.id)
visit url_for(controller: 'cards', action: 'remove', product_id: product.id)
total = 0
Product.all.each do |obj|
total += obj.price
......@@ -179,7 +174,7 @@ describe "CardPages" do
describe "when not pass step 1" do
before do
Product.all.each do |product|
visit cards_path(card_action: 'remove', product_id: product.id)
visit url_for(controller: 'cards', action: 'remove', product_id: product.id)
end
visit url_for(controller: 'cards', action: 'checkout')
......@@ -305,7 +300,7 @@ describe "CardPages" do
describe "when not pass step 1" do
before do
Product.all.each do |product|
visit cards_path(card_action: 'remove', product_id: product.id)
visit url_for(controller: 'cards', action: 'remove', product_id: product.id)
end
visit url_for(controller: 'cards', action: 'confirm_checkout')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment