Sha256: ca294ab7220916cc563749b44b5bf6f48909360d79f475e3292e2e89c36c8991
Contents?: true
Size: 1.91 KB
Versions: 2
Compression:
Stored size: 1.91 KB
Contents
require 'test_helper' require 'queries/user/fetch_in_group_rel' require 'queries/group/filter_with_color' module Inquery class Query class ChainableTest < Minitest::Unit::TestCase include TestHelper def setup self.class.setup_db self.class.setup_base_data end def test_fetch_users_in_group_rels result = Queries::User::FetchInGroupRel.run(Group.where('ID IN (1, 2)')) assert_equal User.find([1, 2, 3]), result.to_a end def test_fetch_users_in_group_rels_with_select # Fetch all groups user 1 is in group_ids_rel = GroupsUser.where(user_id: 1).select(:group_id) # Fetch all users that are in these groups result = Queries::User::FetchInGroupRel.run(group_ids_rel) assert_equal User.find([1, 2, 3]), result.to_a end def test_fetch_red_groups result = Queries::Group::FetchRed.run assert_equal Group.find([1]), result.to_a end def test_fetch_red_groups_via_scope result = Group.red assert_equal Group.find([1]), result.to_a end def test_fetch_green_groups_via_scope result = Group.green assert_equal Group.find([2, 3]), result.to_a end def test_fetch_green_groups_via_scope_with_where # Where before result = Group.where('id > 2').green assert_equal Group.find([3]), result.to_a # Where after result = Group.green.where('id > 2') assert_equal Group.find([3]), result.to_a end def test_fetch_green_groups_with_where # With default scope result = Queries::Group::FetchGreen.run(Group.where('id > 2')) assert_equal Group.find([3]), result.to_a end def test_filter_with_color result = Queries::Group::FilterWithColor.run(Group.where('id > 2'), color: 'green') assert_equal Group.find([3]), result.to_a end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
inquery-0.1.0 | test/inquery/query/chainable_test.rb |
inquery-0.0.1 | test/inquery/query/chainable_test.rb |