Skip to content

Commit

Permalink
Test with ActiveRecord 3.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Jan 2, 2012
1 parent b3ee327 commit 8d0e411
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 41 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- ree
- ree
gemfile:
- Gemfile.rails-3.1
- Gemfile.rails-3.2
22 changes: 1 addition & 21 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@

source :rubygems
source 'http://gems.github.com/'

spec = eval(File.read('grouped_scope.gemspec'))
ar_version = spec.dependencies.detect{ |d|d.name == 'activerecord' }.requirement.to_s
ar_version = ENV['RAILS_VERSION'] || ar_version

gem 'sqlite3', '1.3.4'
gem 'activerecord', ar_version, :require => 'active_record'

group :development do
gem 'rake', '~> 0.9.2'
end

group :test do
gem 'minitest', '~> 2.8.1'
gem 'factory_girl', '~> 2.3.2'
gem 'mocha', '~> 0.10.0'
end

eval File.read('Gemfile.rails-3.1')
9 changes: 9 additions & 0 deletions Gemfile.rails-3.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source :rubygems

spec = eval File.read('grouped_scope.gemspec')
deps = spec.dependencies.map { |dep| {:name => dep.name, :version => dep.requirement.to_s} }

deps.reject! { |dep| dep[:name] =~ /activerecord/ }
deps.each { |dep| gem dep[:name], dep[:version] }

gem 'activerecord', '~> 3.1.3'
9 changes: 9 additions & 0 deletions Gemfile.rails-3.2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source :rubygems

spec = eval File.read('grouped_scope.gemspec')
deps = spec.dependencies.map { |dep| {:name => dep.name, :version => dep.requirement.to_s} }

deps.reject! { |dep| dep[:name] =~ /activerecord/ }
deps.each { |dep| gem dep[:name], dep[:version] }

gem 'activerecord', '3.2.0.rc1'
11 changes: 5 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
require 'rake'
require 'bundler'
require 'rake/testtask'

desc 'Default: run unit tests.'
task :default => :test
Bundler::GemHelper.install_tasks

desc 'Test the GroupedScope plugin.'
Rake::TestTask.new do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.libs = ['lib','test']
t.test_files = Dir.glob("test/**/*_test.rb").sort
t.verbose = true
end

task :default => [:test]
9 changes: 7 additions & 2 deletions grouped_scope.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ Gem::Specification.new do |s|
s.email = ['[email protected]']
s.homepage = 'http://github.com/metaskills/grouped_scope/'
s.summary = 'Extends has_many associations to group scope.'
s.description = 'Extends has_many associations to group scope. For ActiveRecord 3.1!'
s.description = 'Extends has_many associations to group scope. For ActiveRecord!'
s.files = `git ls-files`.split("\n") - ["grouped_scope.gemspec"]
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ['lib']
s.rdoc_options = ['--charset=UTF-8']
s.add_dependency 'activerecord', '~> 3.1.0'
s.add_runtime_dependency 'activerecord', '~> 3.1'
s.add_development_dependency 'sqlite3', '~> 1.3'
s.add_development_dependency 'rake', '~> 0.9.2'
s.add_development_dependency 'minitest', '~> 2.8.1'
s.add_development_dependency 'factory_girl', '~> 2.3.2'
s.add_development_dependency 'mocha', '~> 0.10.0'
end

1 change: 1 addition & 0 deletions lib/grouped_scope.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'active_record'
require 'active_record/version'
require 'grouped_scope/errors'
require 'grouped_scope/self_grouping'
Expand Down
14 changes: 5 additions & 9 deletions lib/grouped_scope/arish/associations/collection_association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ module CollectionAssociation

extend ActiveSupport::Concern

module InstanceMethods

def association_scope
if reflection.grouped_scope?
@association_scope ||= Associations::AssociationScope.new(self).scope if klass
else
super
end
def association_scope
if reflection.grouped_scope?
@association_scope ||= Associations::AssociationScope.new(self).scope if klass
else
super
end

end

end
Expand Down
4 changes: 2 additions & 2 deletions test/helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rubygems'
require 'bundler'
require "bundler/setup"
Bundler.require(:default, :development, :test)
Bundler.require
require 'grouped_scope'
require 'minitest/autorun'
require 'factories'
Expand Down Expand Up @@ -156,7 +156,7 @@ class Employee < ActiveRecord::Base
end

class LegacyEmployee < ActiveRecord::Base
set_primary_key :email
self.primary_key = 'email'
has_many :reports, :class_name => 'LegacyReport', :foreign_key => 'email'
grouped_scope :reports
end
Expand Down

0 comments on commit 8d0e411

Please sign in to comment.