Commit ac4a3164 by vulehuan

change some url when move some card functions to other actions

parent e8c1157b
...@@ -24,12 +24,10 @@ end ...@@ -24,12 +24,10 @@ end
describe "CardPages" do describe "CardPages" do
subject { page } subject { page }
before(:all) do before(:each) do
@product_category = FactoryGirl.create(:product_category) @product_category = FactoryGirl.create(:product_category)
@user = FactoryGirl.create(:user) @user = FactoryGirl.create(:user)
end
before(:each) do
5.times { FactoryGirl.create(:product, product_category_id: @product_category.id, user_id: @user.id) } 5.times { FactoryGirl.create(:product, product_category_id: @product_category.id, user_id: @user.id) }
Product.all.each do |product| Product.all.each do |product|
visit product_path(product) visit product_path(product)
...@@ -37,13 +35,10 @@ describe "CardPages" do ...@@ -37,13 +35,10 @@ describe "CardPages" do
end end
end end
after(:all) do
User.delete_all
ProductCategory.delete_all
end
after(:each) do after(:each) do
Product.delete_all Product.delete_all
User.delete_all
ProductCategory.delete_all
end end
describe "step 1" do describe "step 1" do
...@@ -51,7 +46,7 @@ describe "CardPages" do ...@@ -51,7 +46,7 @@ describe "CardPages" do
describe "with invalid information" do describe "with invalid information" do
describe "when product not exist" do describe "when product not exist" do
before 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 end
it { should have_selector('.alert.alert-error', text: 'Invalid') } it { should have_selector('.alert.alert-error', text: 'Invalid') }
...@@ -60,7 +55,7 @@ describe "CardPages" do ...@@ -60,7 +55,7 @@ describe "CardPages" do
describe "when quantity is not a number" do describe "when quantity is not a number" do
before do before do
product = Product.first 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 end
it { should have_selector('.alert.alert-error', text: 'Invalid') } it { should have_selector('.alert.alert-error', text: 'Invalid') }
...@@ -69,7 +64,7 @@ describe "CardPages" do ...@@ -69,7 +64,7 @@ describe "CardPages" do
describe "when quantity < 0" do describe "when quantity < 0" do
before do before do
product = Product.first 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 end
it { should have_selector('.alert.alert-error', text: 'Invalid') } it { should have_selector('.alert.alert-error', text: 'Invalid') }
...@@ -78,7 +73,7 @@ describe "CardPages" do ...@@ -78,7 +73,7 @@ describe "CardPages" do
describe "when quantity = 0" do describe "when quantity = 0" do
before do before do
product = Product.first 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 end
it { should have_selector('.alert.alert-error', text: 'Invalid') } it { should have_selector('.alert.alert-error', text: 'Invalid') }
...@@ -91,7 +86,7 @@ describe "CardPages" do ...@@ -91,7 +86,7 @@ describe "CardPages" do
let(:product) { Product.first } let(:product) { Product.first }
before do 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 end
it do it do
...@@ -116,7 +111,7 @@ describe "CardPages" do ...@@ -116,7 +111,7 @@ describe "CardPages" do
describe "when product not exist" do describe "when product not exist" do
before do before do
visit cards_path(card_action: 'update', product_id: 0) visit url_for(controller: 'cards', action: 'update', product_id: 0)
end end
it { should have_selector('.alert.alert-error', text: 'Invalid') } it { should have_selector('.alert.alert-error', text: 'Invalid') }
...@@ -126,7 +121,7 @@ describe "CardPages" do ...@@ -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) } let(:product_not_in_card) { FactoryGirl.create(:product, product_category_id: @product_category.id, user_id: @user.id) }
before do 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 end
it { should have_selector('.alert.alert-error', text: 'Invalid') } it { should have_selector('.alert.alert-error', text: 'Invalid') }
...@@ -140,7 +135,7 @@ describe "CardPages" do ...@@ -140,7 +135,7 @@ describe "CardPages" do
total = 0 total = 0
before do 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 total = 0
Product.all.each do |obj| Product.all.each do |obj|
total += obj.price total += obj.price
...@@ -179,7 +174,7 @@ describe "CardPages" do ...@@ -179,7 +174,7 @@ describe "CardPages" do
describe "when not pass step 1" do describe "when not pass step 1" do
before do before do
Product.all.each do |product| 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 end
visit url_for(controller: 'cards', action: 'checkout') visit url_for(controller: 'cards', action: 'checkout')
...@@ -305,7 +300,7 @@ describe "CardPages" do ...@@ -305,7 +300,7 @@ describe "CardPages" do
describe "when not pass step 1" do describe "when not pass step 1" do
before do before do
Product.all.each do |product| 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 end
visit url_for(controller: 'cards', action: 'confirm_checkout') 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