Skip to content

Commit

Permalink
remove deprecated update_attribute method in spec file.
Browse files Browse the repository at this point in the history
  • Loading branch information
saberma committed Aug 1, 2012
1 parent 527b4b5 commit 8fe62b0
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 11 deletions.
5 changes: 4 additions & 1 deletion app/models/order.rb
Expand Up @@ -261,7 +261,10 @@ class OrderTransaction < ActiveRecord::Base

after_create do
amount_sum = self.order.transactions.map(&:amount).sum
self.order.financial_status = :paid if amount_sum >= self.order.total_price
if amount_sum >= self.order.total_price
self.order.financial_status = :paid
self.order.save
end
self.order.histories.create body: "我们已经成功接收款项"
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/shop/collections_controller_spec.rb
Expand Up @@ -43,7 +43,7 @@

it "should view the index collections" do
smart_collection_low_price
iphone4.update_attribute :published, false
iphone4.update_attributes published: false
get 'index'
response.should be_success
response.body.should have_content('首页商品')
Expand Down Expand Up @@ -72,7 +72,7 @@
response.body.should have_content('低价商品')
get 'show', handle: 'low_price'
response.body.should_not have_content("此页面不存在")
smart_collection_low_price.update_attribute :published, false
smart_collection_low_price.update_attributes published: false
iphone4
get 'index'
response.body.should_not have_content('低价商品')
Expand Down
2 changes: 1 addition & 1 deletion spec/liquids/collections_drop_spec.rb
Expand Up @@ -43,7 +43,7 @@
variant = "{% for product in collections.frontpage.products %}<span>{{ product.title }}</span>{% endfor %}"
result = "<span>#{iphone4.title}</span>"
Liquid::Template.parse(variant).render('collections' => collections_drop).should eql result
iphone4.update_attribute :published,false
iphone4.update_attributes published: false
variant = "{% if collections.frontpage.products.size == 0 %}<span>没有商品</span>{% endif %}"
result = "<span>没有商品</span>"
Liquid::Template.parse(variant).render('collections' => collections_drop).should eql result
Expand Down
3 changes: 2 additions & 1 deletion spec/models/discount_spec.rb
Expand Up @@ -26,7 +26,8 @@

let(:discount) do
model = shop.discounts.create code: 'coupon123', usage_limit: 1
model.update_attribute :used_times, 1
model.used_times = 1
model.save
model
end

Expand Down
4 changes: 2 additions & 2 deletions spec/observers/activity_observer_spec.rb
Expand Up @@ -23,11 +23,11 @@
end.to change(Activity,:count).by(1)

expect do
blog.update_attribute 'title', 'bbbbb'
blog.update_attributes title: 'bbbbb'
end.to change(Activity,:count).by(1)

expect do
article.update_attribute 'title', 'cccc'
article.update_attributes title: 'cccc'
end.to change(Activity,:count).by(1)


Expand Down
2 changes: 1 addition & 1 deletion spec/observers/smart_collection_observer_spec.rb
Expand Up @@ -19,7 +19,7 @@
it "should be insert" do
expect do
iphone4
iphone4.update_attribute :body_html, '' #update will not insert again
iphone4.update_attributes body_html: '' #update will not insert again
end.to change(SmartCollectionProduct, :count).by(1)
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/requests/customers_spec.rb
Expand Up @@ -20,7 +20,8 @@
{product_variant: iphone4_variant, price: 10, quantity: 2},
]
o.save
o.update_attribute :financial_status, :pending # 修改为pending会增加消费金额
o.financial_status = :pending # 修改为pending会增加消费金额
o.save
o
end

Expand Down
6 changes: 4 additions & 2 deletions spec/requests/orders_spec.rb
Expand Up @@ -63,7 +63,8 @@
context "#pending" do

before :each do
order.update_attribute :financial_status, :pending # 假设顾客已经提交订单
order.financial_status = :pending # 假设顾客已经提交订单
order.save
end

it "should save fulfillment" do #支持分批发货
Expand Down Expand Up @@ -226,7 +227,8 @@
click_on '放弃'
has_content?(order.name).should be_true
order.update_attribute :financial_status, :pending # 假设顾客已经提交订单
order.financial_status = :pending # 假设顾客已经提交订单
order.save
visit orders_path
has_content?(order.name).should be_true
end
Expand Down

0 comments on commit 8fe62b0

Please sign in to comment.