diff options
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/author.rb | 12 | ||||
-rw-r--r-- | activerecord/test/models/book.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/comment.rb | 4 | ||||
-rw-r--r-- | activerecord/test/models/customer.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/invoice.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/member.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/pirate.rb | 16 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 14 | ||||
-rw-r--r-- | activerecord/test/models/project.rb | 8 | ||||
-rw-r--r-- | activerecord/test/models/sponsor.rb | 2 |
10 files changed, 32 insertions, 32 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 8633504d54..fab613afd1 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -67,13 +67,13 @@ class Author < ActiveRecord::Base before_remove: :log_before_removing, after_remove: :log_after_removing has_many :posts_with_proc_callbacks, class_name: "Post", - before_add: Proc.new {|o, r| o.post_log << "before_adding#{r.id || '<new>'}"}, - after_add: Proc.new {|o, r| o.post_log << "after_adding#{r.id || '<new>'}"}, - before_remove: Proc.new {|o, r| o.post_log << "before_removing#{r.id}"}, - after_remove: Proc.new {|o, r| o.post_log << "after_removing#{r.id}"} + before_add: Proc.new { |o, r| o.post_log << "before_adding#{r.id || '<new>'}" }, + after_add: Proc.new { |o, r| o.post_log << "after_adding#{r.id || '<new>'}" }, + before_remove: Proc.new { |o, r| o.post_log << "before_removing#{r.id}" }, + after_remove: Proc.new { |o, r| o.post_log << "after_removing#{r.id}" } has_many :posts_with_multiple_callbacks, class_name: "Post", - before_add: [:log_before_adding, Proc.new {|o, r| o.post_log << "before_adding_proc#{r.id || '<new>'}"}], - after_add: [:log_after_adding, Proc.new {|o, r| o.post_log << "after_adding_proc#{r.id || '<new>'}"}] + before_add: [:log_before_adding, Proc.new { |o, r| o.post_log << "before_adding_proc#{r.id || '<new>'}" }], + after_add: [:log_after_adding, Proc.new { |o, r| o.post_log << "after_adding_proc#{r.id || '<new>'}" }] has_many :unchangeable_posts, class_name: "Post", before_add: :raise_exception, after_add: :log_after_adding has_many :categorizations diff --git a/activerecord/test/models/book.rb b/activerecord/test/models/book.rb index edd0281127..4c275fdebb 100644 --- a/activerecord/test/models/book.rb +++ b/activerecord/test/models/book.rb @@ -8,7 +8,7 @@ class Book < ActiveRecord::Base has_many :subscribers, through: :subscriptions enum status: [:proposed, :written, :published] - enum read_status: {unread: 0, reading: 2, read: 3} + enum read_status: { unread: 0, reading: 2, read: 3 } enum nullable_status: [:single, :married] enum language: [:english, :spanish, :french], _prefix: :in enum author_visibility: [:visible, :invisible], _prefix: true diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index 7315a1af8e..a4b81d56e0 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -1,5 +1,5 @@ class Comment < ActiveRecord::Base - scope :limit_by, lambda {|l| limit(l) } + scope :limit_by, lambda { |l| limit(l) } scope :containing_the_letter_e, -> { where("comments.body LIKE '%e%'") } scope :not_again, -> { where("comments.body NOT LIKE '%again%'") } scope :for_first_post, -> { where(post_id: 1) } @@ -55,6 +55,6 @@ class CommentThatAutomaticallyAltersPostBody < Comment end class CommentWithDefaultScopeReferencesAssociation < Comment - default_scope ->{ includes(:developer).order("developers.name").references(:developer) } + default_scope -> { includes(:developer).order("developers.name").references(:developer) } belongs_to :developer end diff --git a/activerecord/test/models/customer.rb b/activerecord/test/models/customer.rb index 71afd0866e..60af7c2247 100644 --- a/activerecord/test/models/customer.rb +++ b/activerecord/test/models/customer.rb @@ -5,7 +5,7 @@ class Customer < ActiveRecord::Base composed_of :balance, class_name: "Money", mapping: %w(balance amount), converter: Proc.new(&:to_money) composed_of :gps_location, allow_nil: true composed_of :non_blank_gps_location, class_name: "GpsLocation", allow_nil: true, mapping: %w(gps_location gps_location), - converter: lambda { |gps| self.gps_conversion_was_run = true; gps.blank? ? nil : GpsLocation.new(gps)} + converter: lambda { |gps| self.gps_conversion_was_run = true; gps.blank? ? nil : GpsLocation.new(gps) } composed_of :fullname, mapping: %w(name to_s), constructor: Proc.new { |name| Fullname.parse(name) }, converter: :parse composed_of :fullname_no_converter, mapping: %w(name to_s), class_name: "Fullname" end diff --git a/activerecord/test/models/invoice.rb b/activerecord/test/models/invoice.rb index 44ee717187..4be5a00193 100644 --- a/activerecord/test/models/invoice.rb +++ b/activerecord/test/models/invoice.rb @@ -1,4 +1,4 @@ class Invoice < ActiveRecord::Base has_many :line_items, autosave: true - before_save {|record| record.balance = record.line_items.map(&:amount).sum } + before_save { |record| record.balance = record.line_items.map(&:amount).sum } end diff --git a/activerecord/test/models/member.rb b/activerecord/test/models/member.rb index 93dfc8253f..36f2461b84 100644 --- a/activerecord/test/models/member.rb +++ b/activerecord/test/models/member.rb @@ -5,7 +5,7 @@ class Member < ActiveRecord::Base has_one :club, through: :current_membership has_one :selected_club, through: :selected_membership, source: :club has_one :favourite_club, -> { where "memberships.favourite = ?", true }, through: :membership, source: :club - has_one :hairy_club, -> { where clubs: {name: "Moustache and Eyebrow Fancier Club"} }, through: :membership, source: :club + has_one :hairy_club, -> { where clubs: { name: "Moustache and Eyebrow Fancier Club" } }, through: :membership, source: :club has_one :sponsor, as: :sponsorable has_one :sponsor_club, through: :sponsor has_one :member_detail, inverse_of: false diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb index 80a941874b..2dc8f9bd84 100644 --- a/activerecord/test/models/pirate.rb +++ b/activerecord/test/models/pirate.rb @@ -9,10 +9,10 @@ class Pirate < ActiveRecord::Base before_remove: :log_before_remove, after_remove: :log_after_remove has_and_belongs_to_many :parrots_with_proc_callbacks, class_name: "Parrot", - before_add: proc {|p,pa| p.ship_log << "before_adding_proc_parrot_#{pa.id || '<new>'}"}, - after_add: proc {|p,pa| p.ship_log << "after_adding_proc_parrot_#{pa.id || '<new>'}"}, - before_remove: proc {|p,pa| p.ship_log << "before_removing_proc_parrot_#{pa.id}"}, - after_remove: proc {|p,pa| p.ship_log << "after_removing_proc_parrot_#{pa.id}"} + before_add: proc { |p,pa| p.ship_log << "before_adding_proc_parrot_#{pa.id || '<new>'}" }, + after_add: proc { |p,pa| p.ship_log << "after_adding_proc_parrot_#{pa.id || '<new>'}" }, + before_remove: proc { |p,pa| p.ship_log << "before_removing_proc_parrot_#{pa.id}" }, + after_remove: proc { |p,pa| p.ship_log << "after_removing_proc_parrot_#{pa.id}" } has_and_belongs_to_many :autosaved_parrots, class_name: "Parrot", autosave: true has_many :treasures, as: :looter @@ -28,10 +28,10 @@ class Pirate < ActiveRecord::Base before_remove: :log_before_remove, after_remove: :log_after_remove has_many :birds_with_proc_callbacks, class_name: "Bird", - before_add: proc {|p,b| p.ship_log << "before_adding_proc_bird_#{b.id || '<new>'}"}, - after_add: proc {|p,b| p.ship_log << "after_adding_proc_bird_#{b.id || '<new>'}"}, - before_remove: proc {|p,b| p.ship_log << "before_removing_proc_bird_#{b.id}"}, - after_remove: proc {|p,b| p.ship_log << "after_removing_proc_bird_#{b.id}"} + before_add: proc { |p,b| p.ship_log << "before_adding_proc_bird_#{b.id || '<new>'}" }, + after_add: proc { |p,b| p.ship_log << "after_adding_proc_bird_#{b.id || '<new>'}" }, + before_remove: proc { |p,b| p.ship_log << "before_removing_proc_bird_#{b.id}" }, + after_remove: proc { |p,b| p.ship_log << "after_removing_proc_bird_#{b.id}" } has_many :birds_with_reject_all_blank, class_name: "Bird" has_one :foo_bulb, -> { where name: "foo" }, foreign_key: :car_id, class_name: "Bulb" diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 8bfd79d907..42eff9cff9 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -21,7 +21,7 @@ class Post < ActiveRecord::Base scope :titled_with_an_apostrophe, -> { where("title LIKE '%''%'") } scope :ranked_by_comments, -> { order("comments_count DESC") } - scope :limit_by, lambda {|l| limit(l) } + scope :limit_by, lambda { |l| limit(l) } belongs_to :author @@ -34,8 +34,8 @@ class Post < ActiveRecord::Base has_one :first_comment, -> { order("id ASC") }, class_name: "Comment" has_one :last_comment, -> { order("id desc") }, class_name: "Comment" - scope :with_special_comments, -> { joins(:comments).where(comments: {type: "SpecialComment"}) } - scope :with_very_special_comments, -> { joins(:comments).where(comments: {type: "VerySpecialComment"}) } + scope :with_special_comments, -> { joins(:comments).where(comments: { type: "SpecialComment" }) } + scope :with_very_special_comments, -> { joins(:comments).where(comments: { type: "VerySpecialComment" }) } scope :with_post, ->(post_id) { joins(:comments).where(comments: { post_id: post_id }) } scope :with_comments, -> { preload(:comments) } @@ -141,10 +141,10 @@ class Post < ActiveRecord::Base has_many :people, through: :readers has_many :single_people, through: :readers has_many :people_with_callbacks, source: :person, through: :readers, - before_add: lambda {|owner, reader| log(:added, :before, reader.first_name) }, - after_add: lambda {|owner, reader| log(:added, :after, reader.first_name) }, - before_remove: lambda {|owner, reader| log(:removed, :before, reader.first_name) }, - after_remove: lambda {|owner, reader| log(:removed, :after, reader.first_name) } + before_add: lambda { |owner, reader| log(:added, :before, reader.first_name) }, + after_add: lambda { |owner, reader| log(:added, :after, reader.first_name) }, + before_remove: lambda { |owner, reader| log(:removed, :before, reader.first_name) }, + after_remove: lambda { |owner, reader| log(:removed, :after, reader.first_name) } has_many :skimmers, -> { where skimmer: true }, class_name: "Reader" has_many :impatient_people, through: :skimmers, source: :person diff --git a/activerecord/test/models/project.rb b/activerecord/test/models/project.rb index 4d6b269731..5009f8f54b 100644 --- a/activerecord/test/models/project.rb +++ b/activerecord/test/models/project.rb @@ -7,10 +7,10 @@ class Project < ActiveRecord::Base has_and_belongs_to_many :developers_named_david, -> { where("name = 'David'").distinct }, class_name: "Developer" has_and_belongs_to_many :developers_named_david_with_hash_conditions, -> { where(name: "David").distinct }, class_name: "Developer" has_and_belongs_to_many :salaried_developers, -> { where "salary > 0" }, class_name: "Developer" - has_and_belongs_to_many :developers_with_callbacks, class_name: "Developer", before_add: Proc.new {|o, r| o.developers_log << "before_adding#{r.id || '<new>'}"}, - after_add: Proc.new {|o, r| o.developers_log << "after_adding#{r.id || '<new>'}"}, - before_remove: Proc.new {|o, r| o.developers_log << "before_removing#{r.id}"}, - after_remove: Proc.new {|o, r| o.developers_log << "after_removing#{r.id}"} + has_and_belongs_to_many :developers_with_callbacks, class_name: "Developer", before_add: Proc.new { |o, r| o.developers_log << "before_adding#{r.id || '<new>'}" }, + after_add: Proc.new { |o, r| o.developers_log << "after_adding#{r.id || '<new>'}" }, + before_remove: Proc.new { |o, r| o.developers_log << "before_removing#{r.id}" }, + after_remove: Proc.new { |o, r| o.developers_log << "after_removing#{r.id}" } has_and_belongs_to_many :well_payed_salary_groups, -> { group("developers.salary").having("SUM(salary) > 10000").select("SUM(salary) as salary") }, class_name: "Developer" belongs_to :firm has_one :lead_developer, through: :firm, inverse_of: :contracted_projects diff --git a/activerecord/test/models/sponsor.rb b/activerecord/test/models/sponsor.rb index 175933ccf1..3f142b25fe 100644 --- a/activerecord/test/models/sponsor.rb +++ b/activerecord/test/models/sponsor.rb @@ -2,6 +2,6 @@ class Sponsor < ActiveRecord::Base belongs_to :sponsor_club, class_name: "Club", foreign_key: "club_id" belongs_to :sponsorable, polymorphic: true belongs_to :thing, polymorphic: true, foreign_type: :sponsorable_type, foreign_key: :sponsorable_id - belongs_to :sponsorable_with_conditions, -> { where name: "Ernie"}, polymorphic: true, + belongs_to :sponsorable_with_conditions, -> { where name: "Ernie" }, polymorphic: true, foreign_type: "sponsorable_type", foreign_key: "sponsorable_id" end |