Sha256: 367816df81f595b33dc453eb8e65af52aeea5e4af1e713810dc65e58e0101e34
Contents?: true
Size: 1.54 KB
Versions: 9
Compression:
Stored size: 1.54 KB
Contents
require_relative "../../../test_helper" module Unit module GemExt module ActiveRecord class TestRelation < MiniTest::Test describe ::ActiveRecord::Relation do before do @relation = Office.where(:id => 1) end describe "#qry_options" do it "initiates a DirectiveRecord::Relation instance and returns the query options" do relation = mock relation.expects(:qry_options).returns(:where => "id = 1") DirectiveRecord::Relation.expects(:new).with(@relation).returns(relation) assert_equal({:where => "id = 1"}, @relation.qry_options) end end describe "#to_qry" do it "delegates to its klass with qry_options" do @relation.expects(:qry_options).with("city").returns(:select => "city", :where => ["id = 1"]) Office.expects(:to_qry).with(:select => "city", :where => ["id = 1"]).returns("SELECT city FROM offices WHERE id = 1") assert_equal "SELECT city FROM offices WHERE id = 1", @relation.to_qry("city") end end describe "#qry" do it "delegates to its klass with qry_options" do @relation.expects(:qry_options).with("city").returns(:select => "city", :where => ["id = 1"]) Office.expects(:qry).with(:select => "city", :where => ["id = 1"]).returns(%w(NYC)) assert_equal %w(NYC), @relation.qry("city") end end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems