diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..d3af07d2 --- /dev/null +++ b/Gemfile @@ -0,0 +1,10 @@ +source :rubygems + +gem 'jeweler' + +gem 'activerecord', '>= 2.0.0' + +group :test do + gem 'rspec', '1.3.1' + gem 'sqlite3-ruby' +end diff --git a/Rakefile b/Rakefile index f280b518..45fa6b87 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,8 @@ require 'rubygems' require 'rake' +require 'bundler' + +Bundler.setup begin require 'jeweler' @@ -10,7 +13,7 @@ begin gem.email = "bjohnson@binarylogic.com" gem.homepage = "http://github.com/binarylogic/searchlogic" gem.authors = ["Ben Johnson of Binary Logic"] - gem.add_dependency "activerecord", ">= 2.0.0" + gem.add_bundler_dependencies end Jeweler::GemcutterTasks.new rescue LoadError @@ -29,6 +32,4 @@ Spec::Rake::SpecTask.new(:rcov) do |spec| spec.rcov = true end -task :spec => :check_dependencies - task :default => :spec diff --git a/spec/searchlogic/named_scopes/association_conditions_spec.rb b/spec/searchlogic/named_scopes/association_conditions_spec.rb index e803ff2b..dffc5df3 100644 --- a/spec/searchlogic/named_scopes/association_conditions_spec.rb +++ b/spec/searchlogic/named_scopes/association_conditions_spec.rb @@ -158,7 +158,7 @@ User.named_scope(:orders_big_id, :joins => User.inner_joins(:orders)) Company.users_orders_big_id.proxy_options.should == {:joins=>[" INNER JOIN \"users\" ON users.company_id = companies.id ", " INNER JOIN \"orders\" ON orders.user_id = users.id "]} end - + it "should order the join statements ascending by the fieldnames so that we don't get double joins where the only difference is that the order of the fields is different" do company = Company.create user = company.users.create(:company_id => company.id) @@ -200,4 +200,15 @@ Company.users_id_equals_any([user2.id, user3.id]).all(:select => "DISTINCT companies.*").should == [company2] end -end \ No newline at end of file + + it "should allow dynamic scope generation on associations without losing association scope options" do + pending + user = User.create + Order.create :user => user, :shipped_on => Time.now + Order.create :shipped_on => Time.now + # The next line causes the assertion to fail + Order.named_scope :shipped_on_not_null, :conditions => ['shipped_on is not null'] + user.orders.shipped_on_not_null.shipped_on_greater_than(2.days.ago).count.should == 1 + end + +end