Sha256: 0de0644c61cd54a11d74d7836e8b53d9e69c6e567104e01d0e4cf3eb303c74bb
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
describe ActiveHashRelation do include Helpers context 'scopes' do context 'without parameters' do it "one scope clause" do hash = {scopes: {unsocial: true}} query = HelperClass.new.apply_filters(User.all, hash).to_sql expected_query = q( "SELECT users.* FROM users", "WHERE users.followings_count = 0", "AND users.followers_count = 0" ) expect(strip(query)).to eq expected_query.to_s end it "multiple scope clauses" do hash = {scopes: {unsocial: true, unverified: true}} query = HelperClass.new.apply_filters(User.all, hash).to_sql expected_query = q( "SELECT users.* FROM users", "WHERE users.verified = 'f'", "AND users.followings_count = 0", "AND users.followers_count = 0" ) expect(strip(query)).to eq expected_query.to_s end end context 'with parameters' do it "one scope clause" do hash = {scopes: {created_on: [Date.parse("12-12-1988")]}} query = HelperClass.new.apply_filters(User.all, hash).to_sql expected_query = q( "SELECT users.* FROM users", "WHERE (date(created_at) = '1988-12-12')", ) expect(strip(query)).to eq expected_query.to_s end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
active_hash_relation-1.4.1 | spec/tests/scopes_spec.rb |
active_hash_relation-1.4.0 | spec/tests/scopes_spec.rb |
active_hash_relation-1.2.0 | spec/tests/scopes_spec.rb |