Skip to content

Commit

Permalink
#465, fixed rspec error.
Browse files Browse the repository at this point in the history
  • Loading branch information
saberma committed Aug 15, 2012
1 parent 77d7719 commit 85b97dd
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
Expand Up @@ -31,7 +31,7 @@ App.Views.Product.Show.Edit = Backbone.View.extend
product_type: @$("input[name='product_type']").val(),
vendor: @$("input[name='vendor']").val(),
tags_text: @$("input[name='tags_text']").val(),
collection_ids: _.map @$("input[name='product[collection_ids][]']:checked"), (input) ->
custom_collection_ids: _.map @$("input[name='product[custom_collection_ids][]']:checked"), (input) ->
input.value
},
success: (model, resp) ->
Expand Down
Expand Up @@ -11,7 +11,7 @@ App.Views.Product.Show.Show = Backbone.View.extend
attrs = _.clone @model.attributes
attrs['options'] = @model.options
attrs['tags'] = StringUtils.to_a attrs.tags_text
collections = _.map @model.attributes.collection_ids, (id) ->
collections = _.map @model.attributes.custom_collection_ids, (id) ->
collection =
id: id
title: $("#collection_#{id}").next('label').text()
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/products_controller.rb
Expand Up @@ -14,7 +14,7 @@ class Admin::ProductsController < Admin::AppController
expose(:product_json) do
product.to_json({
include: { options: { methods: [:value, :first, :last], except: [ :created_at, :updated_at ] },photos: {methods: :icon} },
methods: [:tags_text, :collection_ids],
methods: [:tags_text, :custom_collection_ids],
except: [ :created_at, :updated_at ]
})
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/product.rb
Expand Up @@ -11,7 +11,7 @@ class Product < ActiveRecord::Base
has_and_belongs_to_many :tags , order: 'id asc'
# 标签
attr_accessor :tags_text,:images
attr_accessible :handle, :title, :published, :body_html, :price, :product_type, :vendor, :tags_text, :images, :photos_attributes, :variants_attributes, :options_attributes, :collection_ids
attr_accessible :handle, :title, :published, :body_html, :price, :product_type, :vendor, :tags_text, :images, :photos_attributes, :variants_attributes, :options_attributes, :custom_collection_ids

scope :published, where(published: true)

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/products/_collection.html.haml
@@ -1,3 +1,3 @@
%li.product-edit-collection
=check_box_tag 'product[collection_ids][]', collection.id, product.custom_collections.include?(collection) || (collection.handle == 'frontpage' and collection.products.size.zero?), id: "collection_#{collection.id}"
=check_box_tag 'product[custom_collection_ids][]', collection.id, product.custom_collections.include?(collection) || (collection.handle == 'frontpage' and collection.products.size.zero?), id: "collection_#{collection.id}"
%label(for="collection_#{collection.id}")=collection.title
8 changes: 4 additions & 4 deletions spec/controllers/shop/collections_controller_spec.rb
Expand Up @@ -16,7 +16,7 @@

let(:smart_collection_low_price){ Factory(:smart_collection_low_price,handle: 'low_price', shop: shop)}

let(:iphone4) { Factory :iphone4, shop: shop, collections: [frontpage_collection] }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [frontpage_collection] }

before :each do
request.host = "#{shop.primary_domain.host}"
Expand Down Expand Up @@ -145,11 +145,11 @@

context '#show_with_tag' do # 结合标签过滤集合商品

let(:iphone4) { Factory :iphone4, shop: shop, collections: [frontpage_collection], tags_text: '手机, 游戏机, 带拍照功能' }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [frontpage_collection], tags_text: '手机, 游戏机, 带拍照功能' }

let(:psp) { Factory :psp, shop: shop, collections: [frontpage_collection], tags_text: '游戏机, 带拍照功能' }
let(:psp) { Factory :psp, shop: shop, custom_collections: [frontpage_collection], tags_text: '游戏机, 带拍照功能' }

let(:leika) { Factory :leika, shop: shop, collections: [frontpage_collection], tags_text: '相机, 带拍照功能' }
let(:leika) { Factory :leika, shop: shop, custom_collections: [frontpage_collection], tags_text: '相机, 带拍照功能' }

before do
[iphone4, psp]
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/shop/products_controller_spec.rb
Expand Up @@ -14,7 +14,7 @@

let(:frontpage_collection) { shop.custom_collections.where(handle: 'frontpage').first }

let(:iphone4) { Factory :iphone4, shop: shop, collections: [frontpage_collection] }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [frontpage_collection] }

before :each do
request.host = "#{shop.primary_domain.host}"
Expand Down
4 changes: 2 additions & 2 deletions spec/liquids/collections_drop_spec.rb
Expand Up @@ -9,9 +9,9 @@

let(:smart_collection_low_price){ Factory(:smart_collection_low_price, shop: shop)}

let(:iphone4) { Factory :iphone4, shop: shop, collections: [frontpage_collection] }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [frontpage_collection] }

let(:psp) { Factory :psp, shop: shop, collections: [frontpage_collection] }
let(:psp) { Factory :psp, shop: shop, custom_collections: [frontpage_collection] }

let(:collections_drop) { CollectionsDrop.new(shop) }

Expand Down
2 changes: 1 addition & 1 deletion spec/liquids/paginate_filter_spec.rb
Expand Up @@ -9,7 +9,7 @@

let(:collection_drop) { CollectionDrop.new(collection) }

let(:iphone4) { Factory :iphone4, shop: shop, collections: [collection] }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [collection] }

context '#default_pagination' do

Expand Down
2 changes: 1 addition & 1 deletion spec/liquids/tag_filter_spec.rb
Expand Up @@ -58,7 +58,7 @@

let(:collection) { shop.custom_collections.where(handle: 'frontpage').first }

let(:iphone4) { Factory :iphone4, shop: shop, collections: [collection], tags_text: '智能 手机 待机时间长' }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [collection], tags_text: '智能 手机 待机时间长' }

it "should get link to tag url" do
variant = "{{ tag | link_to_tag: tag }}"
Expand Down
2 changes: 1 addition & 1 deletion spec/models/custom_collection_spec.rb
Expand Up @@ -36,7 +36,7 @@

let(:frontpage_collection) { shop.custom_collections.where(handle: 'frontpage').first }

let(:iphone4) { Factory :iphone4, shop: shop, collections: [frontpage_collection] }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [frontpage_collection] }

context 'create' do

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/shop/shops_searches_spec.rb
Expand Up @@ -8,7 +8,7 @@

let(:frontpage_collection) { shop.custom_collections.where(handle: 'frontpage').first }

let(:iphone4) { Factory :iphone4, shop: shop, collections: [frontpage_collection] }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [frontpage_collection] }

# 查询(需要启动全文检索服务) RAILS_ENV=test bundle exec rake sunspot:solr:run
describe "GET /search", searchable: true do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/shop/shops_spec.rb
Expand Up @@ -18,7 +18,7 @@

let(:frontpage_collection) { shop.custom_collections.where(handle: 'frontpage').first }

let(:iphone4) { Factory :iphone4, shop: shop, collections: [frontpage_collection] }
let(:iphone4) { Factory :iphone4, shop: shop, custom_collections: [frontpage_collection] }

let(:payment) { Factory :payment, shop: shop }

Expand Down

0 comments on commit 85b97dd

Please sign in to comment.