diff options
author | Matthew Draper <matthew@trebex.net> | 2018-02-24 17:15:50 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2018-02-24 17:16:13 +1030 |
commit | 4c0a3d48804a363c7e9272519665a21f601b5248 (patch) | |
tree | 6b1f6e28f85cfd69a0ce534856ef939c7079d5cf /activerecord/test/cases/arel/table_test.rb | |
parent | 17ca17072dcdff11b3702a6b45f2fb0c8f8fe9a4 (diff) | |
download | rails-4c0a3d48804a363c7e9272519665a21f601b5248.tar.gz rails-4c0a3d48804a363c7e9272519665a21f601b5248.tar.bz2 rails-4c0a3d48804a363c7e9272519665a21f601b5248.zip |
Arel: rubocop -a
Diffstat (limited to 'activerecord/test/cases/arel/table_test.rb')
-rw-r--r-- | activerecord/test/cases/arel/table_test.rb | 129 |
1 files changed, 65 insertions, 64 deletions
diff --git a/activerecord/test/cases/arel/table_test.rb b/activerecord/test/cases/arel/table_test.rb index ccb3ab302f..91b7a5a480 100644 --- a/activerecord/test/cases/arel/table_test.rb +++ b/activerecord/test/cases/arel/table_test.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require_relative 'helper' + +require_relative "helper" module Arel class TableTest < Arel::Spec @@ -7,56 +8,56 @@ module Arel @relation = Table.new(:users) end - it 'should create join nodes' do - join = @relation.create_string_join 'foo' + it "should create join nodes" do + join = @relation.create_string_join "foo" assert_kind_of Arel::Nodes::StringJoin, join - assert_equal 'foo', join.left + assert_equal "foo", join.left end - it 'should create join nodes' do - join = @relation.create_join 'foo', 'bar' + it "should create join nodes" do + join = @relation.create_join "foo", "bar" assert_kind_of Arel::Nodes::InnerJoin, join - assert_equal 'foo', join.left - assert_equal 'bar', join.right + assert_equal "foo", join.left + assert_equal "bar", join.right end - it 'should create join nodes with a klass' do - join = @relation.create_join 'foo', 'bar', Arel::Nodes::FullOuterJoin + it "should create join nodes with a klass" do + join = @relation.create_join "foo", "bar", Arel::Nodes::FullOuterJoin assert_kind_of Arel::Nodes::FullOuterJoin, join - assert_equal 'foo', join.left - assert_equal 'bar', join.right + assert_equal "foo", join.left + assert_equal "bar", join.right end - it 'should create join nodes with a klass' do - join = @relation.create_join 'foo', 'bar', Arel::Nodes::OuterJoin + it "should create join nodes with a klass" do + join = @relation.create_join "foo", "bar", Arel::Nodes::OuterJoin assert_kind_of Arel::Nodes::OuterJoin, join - assert_equal 'foo', join.left - assert_equal 'bar', join.right + assert_equal "foo", join.left + assert_equal "bar", join.right end - it 'should create join nodes with a klass' do - join = @relation.create_join 'foo', 'bar', Arel::Nodes::RightOuterJoin + it "should create join nodes with a klass" do + join = @relation.create_join "foo", "bar", Arel::Nodes::RightOuterJoin assert_kind_of Arel::Nodes::RightOuterJoin, join - assert_equal 'foo', join.left - assert_equal 'bar', join.right + assert_equal "foo", join.left + assert_equal "bar", join.right end - it 'should return an insert manager' do - im = @relation.compile_insert 'VALUES(NULL)' + it "should return an insert manager" do + im = @relation.compile_insert "VALUES(NULL)" assert_kind_of Arel::InsertManager, im im.into Table.new(:users) assert_equal "INSERT INTO \"users\" VALUES(NULL)", im.to_sql end - describe 'skip' do - it 'should add an offset' do + describe "skip" do + it "should add an offset" do sm = @relation.skip 2 sm.to_sql.must_be_like "SELECT FROM \"users\" OFFSET 2" end end - describe 'having' do - it 'adds a having clause' do + describe "having" do + it "adds a having clause" do mgr = @relation.having @relation[:id].eq(10) mgr.to_sql.must_be_like %{ SELECT FROM "users" HAVING "users"."id" = 10 @@ -64,21 +65,21 @@ module Arel end end - describe 'backwards compat' do - describe 'join' do - it 'noops on nil' do + describe "backwards compat" do + describe "join" do + it "noops on nil" do mgr = @relation.join nil mgr.to_sql.must_be_like %{ SELECT FROM "users" } end - it 'raises EmptyJoinError on empty' do + it "raises EmptyJoinError on empty" do assert_raises(EmptyJoinError) do @relation.join "" end end - it 'takes a second argument for join type' do + it "takes a second argument for join type" do right = @relation.alias predicate = @relation[:id].eq(right[:id]) mgr = @relation.join(right, Nodes::OuterJoin).on(predicate) @@ -91,8 +92,8 @@ module Arel end end - describe 'join' do - it 'creates an outer join' do + describe "join" do + it "creates an outer join" do right = @relation.alias predicate = @relation[:id].eq(right[:id]) mgr = @relation.outer_join(right).on(predicate) @@ -106,8 +107,8 @@ module Arel end end - describe 'group' do - it 'should create a group' do + describe "group" do + it "should create a group" do manager = @relation.group @relation[:id] manager.to_sql.must_be_like %{ SELECT FROM "users" GROUP BY "users"."id" @@ -115,54 +116,54 @@ module Arel end end - describe 'alias' do - it 'should create a node that proxies to a table' do + describe "alias" do + it "should create a node that proxies to a table" do node = @relation.alias - node.name.must_equal 'users_2' + node.name.must_equal "users_2" node[:id].relation.must_equal node end end - describe 'new' do - it 'should accept a hash' do - rel = Table.new :users, :as => 'foo' - rel.table_alias.must_equal 'foo' + describe "new" do + it "should accept a hash" do + rel = Table.new :users, as: "foo" + rel.table_alias.must_equal "foo" end - it 'ignores as if it equals name' do - rel = Table.new :users, :as => 'users' + it "ignores as if it equals name" do + rel = Table.new :users, as: "users" rel.table_alias.must_be_nil end end - describe 'order' do + describe "order" do it "should take an order" do manager = @relation.order "foo" manager.to_sql.must_be_like %{ SELECT FROM "users" ORDER BY foo } end end - describe 'take' do + describe "take" do it "should add a limit" do manager = @relation.take 1 - manager.project Nodes::SqlLiteral.new '*' + manager.project Nodes::SqlLiteral.new "*" manager.to_sql.must_be_like %{ SELECT * FROM "users" LIMIT 1 } end end - describe 'project' do - it 'can project' do - manager = @relation.project Nodes::SqlLiteral.new '*' + describe "project" do + it "can project" do + manager = @relation.project Nodes::SqlLiteral.new "*" manager.to_sql.must_be_like %{ SELECT * FROM "users" } end - it 'takes multiple parameters' do - manager = @relation.project Nodes::SqlLiteral.new('*'), Nodes::SqlLiteral.new('*') + it "takes multiple parameters" do + manager = @relation.project Nodes::SqlLiteral.new("*"), Nodes::SqlLiteral.new("*") manager.to_sql.must_be_like %{ SELECT *, * FROM "users" } end end - describe 'where' do + describe "where" do it "returns a tree manager" do manager = @relation.where @relation[:id].eq 1 manager.project @relation[:id] @@ -176,15 +177,15 @@ module Arel end it "should have a name" do - @relation.name.must_equal 'users' + @relation.name.must_equal "users" end it "should have a table name" do - @relation.table_name.must_equal 'users' + @relation.table_name.must_equal "users" end - describe '[]' do - describe 'when given a Symbol' do + describe "[]" do + describe "when given a Symbol" do it "manufactures an attribute if the symbol names an attribute within the relation" do column = @relation[:id] column.name.must_equal :id @@ -192,21 +193,21 @@ module Arel end end - describe 'equality' do - it 'is equal with equal ivars' do + describe "equality" do + it "is equal with equal ivars" do relation1 = Table.new(:users) - relation1.table_alias = 'zomg' + relation1.table_alias = "zomg" relation2 = Table.new(:users) - relation2.table_alias = 'zomg' + relation2.table_alias = "zomg" array = [relation1, relation2] assert_equal 1, array.uniq.size end - it 'is not equal with different ivars' do + it "is not equal with different ivars" do relation1 = Table.new(:users) - relation1.table_alias = 'zomg' + relation1.table_alias = "zomg" relation2 = Table.new(:users) - relation2.table_alias = 'zomg2' + relation2.table_alias = "zomg2" array = [relation1, relation2] assert_equal 2, array.uniq.size end |