Skip to content

Commit

Permalink
Merge pull request rails#45173 from nvasilevski/change-developer-clas…
Browse files Browse the repository at this point in the history
…s-misleading-name

Change `DeveloperWithDefaultNilableMentorScopeAllQueries` name
  • Loading branch information
yahonda authored May 24, 2022
2 parents 9510783 + 07bae8b commit 06b1000
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions activerecord/test/cases/scoping/default_scoping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_default_scope_with_all_queries_runs_on_create
end

def test_nilable_default_scope_with_all_queries_runs_on_create
create_sql = capture_sql { DeveloperWithDefaultNilableMentorScopeAllQueries.create!(name: "Nikita") }.first
create_sql = capture_sql { DeveloperWithDefaultNilableFirmScopeAllQueries.create!(name: "Nikita") }.first

assert_no_match(/AND$/, create_sql)
end
Expand All @@ -134,8 +134,8 @@ def test_default_scope_with_all_queries_runs_on_select
end

def test_nilable_default_scope_with_all_queries_runs_on_select
DeveloperWithDefaultNilableMentorScopeAllQueries.create!(name: "Nikita")
select_sql = capture_sql { DeveloperWithDefaultNilableMentorScopeAllQueries.find_by(name: "Nikita") }.first
DeveloperWithDefaultNilableFirmScopeAllQueries.create!(name: "Nikita")
select_sql = capture_sql { DeveloperWithDefaultNilableFirmScopeAllQueries.find_by(name: "Nikita") }.first

assert_no_match(/AND$/, select_sql)
end
Expand All @@ -157,7 +157,7 @@ def test_default_scope_with_all_queries_runs_on_update
end

def test_nilable_default_scope_with_all_queries_runs_on_update
dev = DeveloperWithDefaultNilableMentorScopeAllQueries.create!(name: "Nikita")
dev = DeveloperWithDefaultNilableFirmScopeAllQueries.create!(name: "Nikita")
update_sql = capture_sql { dev.update!(name: "Not Nikita") }.first

assert_no_match(/AND$/, update_sql)
Expand All @@ -180,7 +180,7 @@ def test_default_scope_with_all_queries_runs_on_update_columns
end

def test_nilable_default_scope_with_all_queries_runs_on_update_columns
dev = DeveloperWithDefaultNilableMentorScopeAllQueries.create!(name: "Nikita")
dev = DeveloperWithDefaultNilableFirmScopeAllQueries.create!(name: "Nikita")
update_sql = capture_sql { dev.update_columns(name: "Not Nikita") }.first

assert_no_match(/AND$/, update_sql)
Expand All @@ -203,7 +203,7 @@ def test_default_scope_with_all_queries_runs_on_destroy
end

def test_nilable_default_scope_with_all_queries_runs_on_destroy
dev = DeveloperWithDefaultNilableMentorScopeAllQueries.create!(name: "Nikita")
dev = DeveloperWithDefaultNilableFirmScopeAllQueries.create!(name: "Nikita")
destroy_sql = capture_sql { dev.destroy }.first

assert_no_match(/AND$/, destroy_sql)
Expand All @@ -226,7 +226,7 @@ def test_default_scope_with_all_queries_runs_on_reload
end

def test_nilable_default_scope_with_all_queries_runs_on_reload
dev = DeveloperWithDefaultNilableMentorScopeAllQueries.create!(name: "Nikita")
dev = DeveloperWithDefaultNilableFirmScopeAllQueries.create!(name: "Nikita")
reload_sql = capture_sql { dev.reload }.first

assert_no_match(/AND$/, reload_sql)
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/models/developer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class DeveloperWithDefaultMentorScopeAllQueries < ActiveRecord::Base
default_scope -> { where(mentor_id: 1) }, all_queries: true
end

class DeveloperWithDefaultNilableMentorScopeAllQueries < ActiveRecord::Base
class DeveloperWithDefaultNilableFirmScopeAllQueries < ActiveRecord::Base
self.table_name = "developers"
firm_id = nil # Could be something like Current.firm_id
default_scope -> { where(firm_id: firm_id) if firm_id }, all_queries: true
Expand Down

0 comments on commit 06b1000

Please sign in to comment.