Skip to content

Commit

Permalink
Update for Spree 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Dutil committed Apr 6, 2013
1 parent 201b137 commit 5dfdfd5
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 46 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'http://rubygems.org'

gem "spree_auth_devise", :git => 'git://github.com/spree/spree_auth_devise.git', :branch => '1-3-stable'
gem 'spree', github: 'spree/spree'
gem "spree_auth_devise", github: 'spree/spree_auth_devise'

gemspec
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ In your application Gemfile, add this gem after the Spree gem:
gem 'spree'
gem 'spree_product_groups', :git => '[email protected]:spree/spree_product_groups.git'
```

Then run:

```
$ bundle
$ rails g spree_product_groups:install
```shell
bundle
rails g spree_product_groups:install
```

Testing
-------

Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.

$ bundle
$ bundle exec rake test_app
$ bundle exec rspec spec
```shell
bundle
bundle exec rake test_app
bundle exec rspec spec
```

Copyright (c) 2012 Spree Commerce, released under the New BSD License
Copyright (c) 2012-2013 Spree Commerce, released under the New BSD License
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'rake/testtask'
require 'rake/packagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'spree/core/testing_support/common_rake'
require 'spree/testing_support/common_rake'

RSpec::Core::RakeTask.new

Expand Down
3 changes: 2 additions & 1 deletion Versionfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# "0.60.x" => { :branch => "0-60-stable" }
# "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }

"1.3.x" => { :branch => "master" }
"2.0.x" => { :branch => "master" }
"1.3.x" => { :branch => "1-3-stable" }
"1.2.x" => { :ref => "fc15293b5ba2f6f1ee5810226940dc0b965d461a" }
"1.1.x" => { :ref => "fc15293b5ba2f6f1ee5810226940dc0b965d461a" }
2 changes: 0 additions & 2 deletions app/models/spree/product_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ class ProductScope < ActiveRecord::Base

validate :check_validity_of_scope

extend ::Spree::Scopes::Dynamic

attr_accessible :name, :arguments

# Get all products with this scope
Expand Down
1 change: 0 additions & 1 deletion lib/spree/core/search/product_group_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def get_base_scope
base_scope = base_scope.in_taxon(taxon) unless taxon.blank?
base_scope = get_products_conditions_for(base_scope, keywords) unless keywords.blank?

base_scope = base_scope.on_hand unless Spree::Config[:show_zero_stock_products]
base_scope = base_scope.group_by_products_id if @product_group.product_scopes.size > 1
base_scope
end
Expand Down
1 change: 0 additions & 1 deletion lib/spree_product_groups.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
require 'spree_core'
require 'spree_promo'
require 'spree_product_groups/engine'
4 changes: 2 additions & 2 deletions spec/factories/product_scope_factory.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FactoryGirl.define do
factory :product_scope, :class => Spree::ProductScope do
product_group { Factory(:product_group) }
name 'on_hand'
product_group { create(:product_group) }
name 'with_ids'
arguments 'some arguments'
end
end
4 changes: 2 additions & 2 deletions spec/models/product/scopes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
describe "product scopes" do

it ".in_cached_group" do
product = Factory(:product)
product_group = Factory(:product_group)
product = create(:product)
product_group = create(:product_group)
product_group.products << product
Spree::Product.in_cached_group(product_group).should include(product)
end
Expand Down
14 changes: 7 additions & 7 deletions spec/models/product_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
describe '#dynamic_products' do

context 'with a scope named with_ids' do
let!(:product_1) { Factory(:product) }
let!(:product_2) { Factory(:product) }
let!(:product_3) { Factory(:product) }
let!(:product_1) { create(:product) }
let!(:product_2) { create(:product) }
let!(:product_3) { create(:product) }
let!(:product_group) do
product_group = Factory(:product_group, :name => "With IDs")
product_group = create(:product_group, :name => "With IDs")
product_group.product_scopes.create!(:name => "with_ids", :arguments => ["#{product_1.id},#{product_2.id}"])
product_group
end
Expand Down Expand Up @@ -58,15 +58,15 @@

# Regression test for #774
context "Regression test for #774" do
let!(:property) { Factory(:property, :name => "test") }
let!(:property) { create(:property, :name => "test") }
let!(:product) do
product = Factory(:product)
product = create(:product)
product.properties << property
product
end

let!(:product_group) do
product_group = Factory(:product_group, :name => "Not sports")
product_group = create(:product_group, :name => "Not sports")
product_group.product_scopes.create!(:name => "with_property", :arguments => ["test"])
product_group
end
Expand Down
8 changes: 4 additions & 4 deletions spec/models/product_scope_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# FIXME use factory in the following test
context "#check_validity_of_scope" do
before do
@pg = Factory(:product_group)
@pg = create(:product_group)
#@ps = Spree::ProductScope.create(:name => 'in_name', :arguments => ['Rails'], :product_group_id => @pg.id)
end
it 'should be valid' do
Expand Down Expand Up @@ -37,9 +37,9 @@
end

context 'when scope name is with_ids' do
let!(:product_1) { Factory(:product) }
let!(:product_2) { Factory(:product) }
let!(:product_3) { Factory(:product) }
let!(:product_1) { create(:product) }
let!(:product_2) { create(:product) }
let!(:product_3) { create(:product) }

it 'should properly pass ids to scope' do
subject.name = 'with_ids'
Expand Down
2 changes: 1 addition & 1 deletion spec/models/product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Spree::Product do

context "shoulda validations" do
let(:product) {Factory(:product)}
let(:product) { create(:product) }
it { should have_and_belong_to_many(:product_groups) }
end

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/admin/homepage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe "Homepage" do
context "visiting the products tab" do
before(:each) do
sign_in_as!(Factory(:admin_user))
sign_in_as!(create(:admin_user))
visit spree.admin_products_path
end

Expand Down
12 changes: 6 additions & 6 deletions spec/requests/admin/products/product_groups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

describe "Product Groups" do
before(:each) do
sign_in_as!(Factory(:admin_user))
sign_in_as!(create(:admin_user))
visit spree.admin_path
click_link "Products"
end

context "listing product groups" do
it "should display existing product groups" do
Factory(:product_group)
Factory(:product_group, :name => 'casual')
create(:product_group)
create(:product_group, :name => 'casual')

click_link "Product Groups"
find('table#listing_product_groups tbody tr:nth-child(1) td:nth-child(1)').text.should == 'sports'
Expand All @@ -31,7 +31,7 @@

context "updating an existing product group" do
it "should allow an admin to update an existing product group" do
Factory(:product_group)
create(:product_group)
click_link "Product Groups"
within('table#listing_product_groups tbody tr:nth-child(1)') { click_link "Edit" }
fill_in "product_group_name", :with => "most popular rails items 99"
Expand All @@ -42,7 +42,7 @@
end

it "should handle permalink changes" do
Factory(:product_group)
create(:product_group)
click_link "Product Groups"
within('table#listing_product_groups tbody tr:nth-child(1)') { click_link "Edit" }

Expand All @@ -66,7 +66,7 @@

context "scoping" do
before(:each) do
Factory(:product_group)
create(:product_group)
click_link "Product Groups"
end

Expand Down
8 changes: 5 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require File.expand_path("../dummy/config/environment.rb", __FILE__)

require 'factory_girl'
require 'ffaker'
require 'rspec/rails'
require 'shoulda-matchers'
Expand All @@ -12,8 +13,8 @@
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }

# Requires factories defined in spree_core
require 'spree/core/testing_support/factories'
require 'spree/core/url_helpers'
require 'spree/testing_support/factories'
require 'spree/testing_support/url_helpers'

Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f|
fp = File.expand_path(f)
Expand All @@ -39,5 +40,6 @@
config.use_transactional_fixtures = true

config.include AuthenticationHelpers, :type => :request
config.include Spree::Core::UrlHelpers
config.include FactoryGirl::Syntax::Methods
config.include Spree::TestingSupport::UrlHelpers
end
2 changes: 1 addition & 1 deletion spec/support/have_valid_factory.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# valid factory tests
RSpec::Matchers.define :have_valid_factory do |factory_name|
match do |model|
Factory(factory_name).new_record?.should be_false
create(factory_name).new_record?.should be_false
end
end
10 changes: 5 additions & 5 deletions spree_product_groups.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Gem::Specification.new do |s|
s.email = '[email protected]'
s.homepage = 'http://www.spreecommerce.com'

#s.files = `git ls-files`.split("\n")
#s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_path = 'lib'
s.requirements << 'none'

s.add_dependency 'spree_core', '~> 1.3.0'
s.add_dependency 'spree_promo', '~> 1.3.0'
s.add_dependency 'spree_core', '~> 2.0.0.beta'

s.add_development_dependency 'capybara', '1.0.1'
s.add_development_dependency 'factory_girl', '~> 2.6'
s.add_development_dependency 'factory_girl', '~> 4.2'
s.add_development_dependency 'ffaker'
s.add_development_dependency 'rspec-rails', '~> 2.7'
s.add_development_dependency 'shoulda-matchers'
s.add_development_dependency 'spree_auth_devise'
s.add_development_dependency 'sqlite3'
end

0 comments on commit 5dfdfd5

Please sign in to comment.