aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 18:26:20 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 18:26:53 +0200
commit9617db2078e8a85c8944392c21dd748f932bbd80 (patch)
tree727d60f1d2f9bbb6510483c366f62d75e2647619 /activerecord/test/models
parent4df2b779ddfcb27761c71e00e2b241bfa06a0950 (diff)
downloadrails-9617db2078e8a85c8944392c21dd748f932bbd80.tar.gz
rails-9617db2078e8a85c8944392c21dd748f932bbd80.tar.bz2
rails-9617db2078e8a85c8944392c21dd748f932bbd80.zip
applies new string literal convention in activerecord/test
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/admin.rb2
-rw-r--r--activerecord/test/models/admin/user.rb6
-rw-r--r--activerecord/test/models/author.rb62
-rw-r--r--activerecord/test/models/book.rb4
-rw-r--r--activerecord/test/models/bulb.rb4
-rw-r--r--activerecord/test/models/car.rb12
-rw-r--r--activerecord/test/models/categorization.rb8
-rw-r--r--activerecord/test/models/category.rb18
-rw-r--r--activerecord/test/models/club.rb2
-rw-r--r--activerecord/test/models/college.rb4
-rw-r--r--activerecord/test/models/comment.rb8
-rw-r--r--activerecord/test/models/company.rb44
-rw-r--r--activerecord/test/models/company_in_module.rb26
-rw-r--r--activerecord/test/models/computer.rb2
-rw-r--r--activerecord/test/models/contact.rb8
-rw-r--r--activerecord/test/models/content.rb6
-rw-r--r--activerecord/test/models/contract.rb2
-rw-r--r--activerecord/test/models/course.rb2
-rw-r--r--activerecord/test/models/developer.rb102
-rw-r--r--activerecord/test/models/doubloon.rb2
-rw-r--r--activerecord/test/models/edge.rb4
-rw-r--r--activerecord/test/models/engine.rb2
-rw-r--r--activerecord/test/models/face.rb2
-rw-r--r--activerecord/test/models/friendship.rb6
-rw-r--r--activerecord/test/models/hotel.rb4
-rw-r--r--activerecord/test/models/job.rb2
-rw-r--r--activerecord/test/models/joke.rb4
-rw-r--r--activerecord/test/models/keyboard.rb2
-rw-r--r--activerecord/test/models/man.rb10
-rw-r--r--activerecord/test/models/matey.rb2
-rw-r--r--activerecord/test/models/member.rb2
-rw-r--r--activerecord/test/models/membership.rb2
-rw-r--r--activerecord/test/models/node.rb4
-rw-r--r--activerecord/test/models/order.rb4
-rw-r--r--activerecord/test/models/organization.rb2
-rw-r--r--activerecord/test/models/owner.rb4
-rw-r--r--activerecord/test/models/parrot.rb2
-rw-r--r--activerecord/test/models/person.rb56
-rw-r--r--activerecord/test/models/pet.rb2
-rw-r--r--activerecord/test/models/pirate.rb20
-rw-r--r--activerecord/test/models/possession.rb2
-rw-r--r--activerecord/test/models/post.rb76
-rw-r--r--activerecord/test/models/professor.rb2
-rw-r--r--activerecord/test/models/project.rb6
-rw-r--r--activerecord/test/models/reader.rb2
-rw-r--r--activerecord/test/models/reference.rb2
-rw-r--r--activerecord/test/models/reply.rb8
-rw-r--r--activerecord/test/models/ship.rb6
-rw-r--r--activerecord/test/models/sponsor.rb4
-rw-r--r--activerecord/test/models/subject.rb2
-rw-r--r--activerecord/test/models/subscriber.rb2
-rw-r--r--activerecord/test/models/tag.rb4
-rw-r--r--activerecord/test/models/tagging.rb8
-rw-r--r--activerecord/test/models/topic.rb14
-rw-r--r--activerecord/test/models/treasure.rb2
-rw-r--r--activerecord/test/models/user.rb4
-rw-r--r--activerecord/test/models/vegetables.rb4
-rw-r--r--activerecord/test/models/vertex.rb6
58 files changed, 307 insertions, 307 deletions
diff --git a/activerecord/test/models/admin.rb b/activerecord/test/models/admin.rb
index a38e3f4846..bc3ce23447 100644
--- a/activerecord/test/models/admin.rb
+++ b/activerecord/test/models/admin.rb
@@ -1,5 +1,5 @@
module Admin
def self.table_name_prefix
- 'admin_'
+ "admin_"
end
end
diff --git a/activerecord/test/models/admin/user.rb b/activerecord/test/models/admin/user.rb
index 48a110bd23..3cd829a8d5 100644
--- a/activerecord/test/models/admin/user.rb
+++ b/activerecord/test/models/admin/user.rb
@@ -26,15 +26,15 @@ class Admin::User < ActiveRecord::Base
end
def phone_number=(value)
- write_store_attribute(:settings, :phone_number, value && value.gsub(/[^\d]/,''))
+ write_store_attribute(:settings, :phone_number, value && value.gsub(/[^\d]/,""))
end
def color
- super || 'red'
+ super || "red"
end
def color=(value)
- value = 'blue' unless %w(black red green blue).include?(value)
+ value = "blue" unless %w(black red green blue).include?(value)
super
end
end
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index 38b983eda0..a9f3063736 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -5,60 +5,60 @@ class Author < ActiveRecord::Base
has_many :very_special_comments, :through => :posts
has_many :posts_with_comments, -> { includes(:comments) }, :class_name => "Post"
has_many :popular_grouped_posts, -> { includes(:comments).group("type").having("SUM(comments_count) > 1").select("type") }, :class_name => "Post"
- has_many :posts_with_comments_sorted_by_comment_id, -> { includes(:comments).order('comments.id') }, :class_name => "Post"
- has_many :posts_sorted_by_id_limited, -> { order('posts.id').limit(1) }, :class_name => "Post"
+ has_many :posts_with_comments_sorted_by_comment_id, -> { includes(:comments).order("comments.id") }, :class_name => "Post"
+ has_many :posts_sorted_by_id_limited, -> { order("posts.id").limit(1) }, :class_name => "Post"
has_many :posts_with_categories, -> { includes(:categories) }, :class_name => "Post"
has_many :posts_with_comments_and_categories, -> { includes(:comments, :categories).order("posts.id") }, :class_name => "Post"
- has_many :posts_with_special_categorizations, :class_name => 'PostWithSpecialCategorization'
- has_one :post_about_thinking, -> { where("posts.title like '%thinking%'") }, :class_name => 'Post'
- has_one :post_about_thinking_with_last_comment, -> { where("posts.title like '%thinking%'").includes(:last_comment) }, :class_name => 'Post'
+ has_many :posts_with_special_categorizations, :class_name => "PostWithSpecialCategorization"
+ has_one :post_about_thinking, -> { where("posts.title like '%thinking%'") }, :class_name => "Post"
+ has_one :post_about_thinking_with_last_comment, -> { where("posts.title like '%thinking%'").includes(:last_comment) }, :class_name => "Post"
has_many :comments, through: :posts do
def ratings
Rating.joins(:comment).merge(self)
end
end
has_many :comments_containing_the_letter_e, :through => :posts, :source => :comments
- has_many :comments_with_order_and_conditions, -> { order('comments.body').where("comments.body like 'Thank%'") }, :through => :posts, :source => :comments
+ has_many :comments_with_order_and_conditions, -> { order("comments.body").where("comments.body like 'Thank%'") }, :through => :posts, :source => :comments
has_many :comments_with_include, -> { includes(:post) }, :through => :posts, :source => :comments
has_many :first_posts
- has_many :comments_on_first_posts, -> { order('posts.id desc, comments.id asc') }, :through => :first_posts, :source => :comments
+ has_many :comments_on_first_posts, -> { order("posts.id desc, comments.id asc") }, :through => :first_posts, :source => :comments
has_one :first_post
- has_one :comment_on_first_post, -> { order('posts.id desc, comments.id asc') }, :through => :first_post, :source => :comments
+ has_one :comment_on_first_post, -> { order("posts.id desc, comments.id asc") }, :through => :first_post, :source => :comments
- has_many :thinking_posts, -> { where(:title => 'So I was thinking') }, :dependent => :delete_all, :class_name => 'Post'
- has_many :welcome_posts, -> { where(:title => 'Welcome to the weblog') }, :class_name => 'Post'
+ has_many :thinking_posts, -> { where(:title => "So I was thinking") }, :dependent => :delete_all, :class_name => "Post"
+ has_many :welcome_posts, -> { where(:title => "Welcome to the weblog") }, :class_name => "Post"
has_many :welcome_posts_with_one_comment,
- -> { where(title: 'Welcome to the weblog').where('comments_count = ?', 1) },
- class_name: 'Post'
+ -> { where(title: "Welcome to the weblog").where("comments_count = ?", 1) },
+ class_name: "Post"
has_many :welcome_posts_with_comments,
- -> { where(title: 'Welcome to the weblog').where(Post.arel_table[:comments_count].gt(0)) },
- class_name: 'Post'
+ -> { where(title: "Welcome to the weblog").where(Post.arel_table[:comments_count].gt(0)) },
+ class_name: "Post"
- has_many :comments_desc, -> { order('comments.id DESC') }, :through => :posts, :source => :comments
+ has_many :comments_desc, -> { order("comments.id DESC") }, :through => :posts, :source => :comments
has_many :funky_comments, :through => :posts, :source => :comments
- has_many :ordered_uniq_comments, -> { distinct.order('comments.id') }, :through => :posts, :source => :comments
- has_many :ordered_uniq_comments_desc, -> { distinct.order('comments.id DESC') }, :through => :posts, :source => :comments
+ has_many :ordered_uniq_comments, -> { distinct.order("comments.id") }, :through => :posts, :source => :comments
+ has_many :ordered_uniq_comments_desc, -> { distinct.order("comments.id DESC") }, :through => :posts, :source => :comments
has_many :readonly_comments, -> { readonly }, :through => :posts, :source => :comments
has_many :special_posts
has_many :special_post_comments, :through => :special_posts, :source => :comments
- has_many :special_posts_with_default_scope, :class_name => 'SpecialPostWithDefaultScope'
+ has_many :special_posts_with_default_scope, :class_name => "SpecialPostWithDefaultScope"
- has_many :sti_posts, :class_name => 'StiPost'
+ has_many :sti_posts, :class_name => "StiPost"
has_many :sti_post_comments, :through => :sti_posts, :source => :comments
has_many :special_nonexistent_posts, -> { where("posts.body = 'nonexistent'") }, :class_name => "SpecialPost"
- has_many :special_nonexistent_post_comments, -> { where('comments.post_id' => 0) }, :through => :special_nonexistent_posts, :source => :comments
+ has_many :special_nonexistent_post_comments, -> { where("comments.post_id" => 0) }, :through => :special_nonexistent_posts, :source => :comments
has_many :nonexistent_comments, :through => :posts
has_many :hello_posts, -> { where "posts.body = 'hello'" }, :class_name => "Post"
has_many :hello_post_comments, :through => :hello_posts, :source => :comments
- has_many :posts_with_no_comments, -> { where('comments.id' => nil).includes(:comments) }, :class_name => 'Post'
+ has_many :posts_with_no_comments, -> { where("comments.id" => nil).includes(:comments) }, :class_name => "Post"
- has_many :hello_posts_with_hash_conditions, -> { where(:body => 'hello') }, :class_name => "Post"
+ has_many :hello_posts_with_hash_conditions, -> { where(:body => "hello") }, :class_name => "Post"
has_many :hello_post_comments_with_hash_conditions, :through =>
:hello_posts_with_hash_conditions, :source => :comments
@@ -85,15 +85,15 @@ class Author < ActiveRecord::Base
has_many :special_categories, :through => :special_categorizations, :source => :category
has_one :special_category, :through => :special_categorizations, :source => :category
- has_many :categories_like_general, -> { where(:name => 'General') }, :through => :categorizations, :source => :category, :class_name => 'Category'
+ has_many :categories_like_general, -> { where(:name => "General") }, :through => :categorizations, :source => :category, :class_name => "Category"
has_many :categorized_posts, :through => :categorizations, :source => :post
has_many :unique_categorized_posts, -> { distinct }, :through => :categorizations, :source => :post
- has_many :nothings, :through => :kateggorisatons, :class_name => 'Category'
+ has_many :nothings, :through => :kateggorisatons, :class_name => "Category"
has_many :author_favorites
- has_many :favorite_authors, -> { order('name') }, :through => :author_favorites
+ has_many :favorite_authors, -> { order("name") }, :through => :author_favorites
has_many :taggings, :through => :posts, :source => :taggings
has_many :taggings_2, :through => :posts, :source => :tagging
@@ -115,17 +115,17 @@ class Author < ActiveRecord::Base
has_one :essay_category, :through => :essay, :source => :category
has_one :essay_owner, :through => :essay, :source => :owner
- has_one :essay_2, :primary_key => :name, :class_name => 'Essay', :foreign_key => :author_id
+ has_one :essay_2, :primary_key => :name, :class_name => "Essay", :foreign_key => :author_id
has_one :essay_category_2, :through => :essay_2, :source => :category
has_many :essays, :primary_key => :name, :as => :writer
has_many :essay_categories, :through => :essays, :source => :category
has_many :essay_owners, :through => :essays, :source => :owner
- has_many :essays_2, :primary_key => :name, :class_name => 'Essay', :foreign_key => :author_id
+ has_many :essays_2, :primary_key => :name, :class_name => "Essay", :foreign_key => :author_id
has_many :essay_categories_2, :through => :essays_2, :source => :category
- belongs_to :owned_essay, :primary_key => :name, :class_name => 'Essay'
+ belongs_to :owned_essay, :primary_key => :name, :class_name => "Essay"
has_one :owned_essay_category, :through => :owned_essay, :source => :category
belongs_to :author_address, :dependent => :destroy
@@ -133,13 +133,13 @@ class Author < ActiveRecord::Base
has_many :category_post_comments, :through => :categories, :source => :post_comments
- has_many :misc_posts, -> { where(:posts => { :title => ['misc post by bob', 'misc post by mary'] }) }, :class_name => 'Post'
+ has_many :misc_posts, -> { where(:posts => { :title => ["misc post by bob", "misc post by mary"] }) }, :class_name => "Post"
has_many :misc_post_first_blue_tags, :through => :misc_posts, :source => :first_blue_tags
- has_many :misc_post_first_blue_tags_2, -> { where(:posts => { :title => ['misc post by bob', 'misc post by mary'] }) },
+ has_many :misc_post_first_blue_tags_2, -> { where(:posts => { :title => ["misc post by bob", "misc post by mary"] }) },
:through => :posts, :source => :first_blue_tags_2
- has_many :posts_with_default_include, :class_name => 'PostWithDefaultInclude'
+ has_many :posts_with_default_include, :class_name => "PostWithDefaultInclude"
has_many :comments_on_posts_with_default_include, :through => :posts_with_default_include, :source => :comments
has_many :posts_with_signature, ->(record) { where("posts.title LIKE ?", "%by #{record.name.downcase}%") }, class_name: "Post"
diff --git a/activerecord/test/models/book.rb b/activerecord/test/models/book.rb
index e43e5c3901..5db4f64b74 100644
--- a/activerecord/test/models/book.rb
+++ b/activerecord/test/models/book.rb
@@ -1,7 +1,7 @@
class Book < ActiveRecord::Base
has_many :authors
- has_many :citations, :foreign_key => 'book1_id'
+ has_many :citations, :foreign_key => "book1_id"
has_many :references, -> { distinct }, through: :citations, source: :reference_of
has_many :subscriptions
@@ -14,7 +14,7 @@ class Book < ActiveRecord::Base
enum author_visibility: [:visible, :invisible], _prefix: true
enum illustrator_visibility: [:visible, :invisible], _prefix: true
enum font_size: [:small, :medium, :large], _prefix: :with, _suffix: true
- enum cover: { hard: 'hard', soft: 'soft' }
+ enum cover: { hard: "hard", soft: "soft" }
def published!
super
diff --git a/activerecord/test/models/bulb.rb b/activerecord/test/models/bulb.rb
index dc0296305a..88baa60035 100644
--- a/activerecord/test/models/bulb.rb
+++ b/activerecord/test/models/bulb.rb
@@ -1,5 +1,5 @@
class Bulb < ActiveRecord::Base
- default_scope { where(:name => 'defaulty') }
+ default_scope { where(:name => "defaulty") }
belongs_to :car, :touch => true
scope :awesome, -> { where(frickinawesome: true) }
@@ -35,7 +35,7 @@ class CustomBulb < Bulb
after_initialize :set_awesomeness
def set_awesomeness
- self.frickinawesome = true if name == 'Dude'
+ self.frickinawesome = true if name == "Dude"
end
end
diff --git a/activerecord/test/models/car.rb b/activerecord/test/models/car.rb
index 0f37e9a289..9f129689ef 100644
--- a/activerecord/test/models/car.rb
+++ b/activerecord/test/models/car.rb
@@ -1,9 +1,9 @@
class Car < ActiveRecord::Base
has_many :bulbs
has_many :all_bulbs, -> { unscope where: :name }, class_name: "Bulb"
- has_many :funky_bulbs, class_name: 'FunkyBulb', dependent: :destroy
- has_many :failed_bulbs, class_name: 'FailedBulb', dependent: :destroy
- has_many :foo_bulbs, -> { where(:name => 'foo') }, :class_name => "Bulb"
+ has_many :funky_bulbs, class_name: "FunkyBulb", dependent: :destroy
+ has_many :failed_bulbs, class_name: "FailedBulb", dependent: :destroy
+ has_many :foo_bulbs, -> { where(:name => "foo") }, :class_name => "Bulb"
has_many :awesome_bulbs, -> { awesome }, class_name: "Bulb"
has_one :bulb
@@ -17,13 +17,13 @@ class Car < ActiveRecord::Base
scope :incl_tyres, -> { includes(:tyres) }
scope :incl_engines, -> { includes(:engines) }
- scope :order_using_new_style, -> { order('name asc') }
+ scope :order_using_new_style, -> { order("name asc") }
end
class CoolCar < Car
- default_scope { order('name desc') }
+ default_scope { order("name desc") }
end
class FastCar < Car
- default_scope { order('name desc') }
+ default_scope { order("name desc") }
end
diff --git a/activerecord/test/models/categorization.rb b/activerecord/test/models/categorization.rb
index 4cd67c970a..178aff0541 100644
--- a/activerecord/test/models/categorization.rb
+++ b/activerecord/test/models/categorization.rb
@@ -1,17 +1,17 @@
class Categorization < ActiveRecord::Base
belongs_to :post
belongs_to :category, counter_cache: true
- belongs_to :named_category, :class_name => 'Category', :foreign_key => :named_category_name, :primary_key => :name
+ belongs_to :named_category, :class_name => "Category", :foreign_key => :named_category_name, :primary_key => :name
belongs_to :author
has_many :post_taggings, :through => :author, :source => :taggings
- belongs_to :author_using_custom_pk, :class_name => 'Author', :foreign_key => :author_id, :primary_key => :author_address_extra_id
- has_many :authors_using_custom_pk, :class_name => 'Author', :foreign_key => :id, :primary_key => :category_id
+ belongs_to :author_using_custom_pk, :class_name => "Author", :foreign_key => :author_id, :primary_key => :author_address_extra_id
+ has_many :authors_using_custom_pk, :class_name => "Author", :foreign_key => :id, :primary_key => :category_id
end
class SpecialCategorization < ActiveRecord::Base
- self.table_name = 'categorizations'
+ self.table_name = "categorizations"
default_scope { where(:special => true) }
belongs_to :author
diff --git a/activerecord/test/models/category.rb b/activerecord/test/models/category.rb
index 272223e1d8..0c6794ff65 100644
--- a/activerecord/test/models/category.rb
+++ b/activerecord/test/models/category.rb
@@ -5,20 +5,20 @@ class Category < ActiveRecord::Base
has_and_belongs_to_many :posts_with_authors_sorted_by_author_id, -> { includes(:authors).order("authors.id") }, :class_name => "Post"
has_and_belongs_to_many :select_testing_posts,
- -> { select 'posts.*, 1 as correctness_marker' },
- :class_name => 'Post',
- :foreign_key => 'category_id',
- :association_foreign_key => 'post_id'
+ -> { select "posts.*, 1 as correctness_marker" },
+ :class_name => "Post",
+ :foreign_key => "category_id",
+ :association_foreign_key => "post_id"
has_and_belongs_to_many :post_with_conditions,
- -> { where :title => 'Yet Another Testing Title' },
- :class_name => 'Post'
+ -> { where :title => "Yet Another Testing Title" },
+ :class_name => "Post"
has_and_belongs_to_many :popular_grouped_posts, -> { group("posts.type").having("sum(comments.post_id) > 2").includes(:comments) }, :class_name => "Post"
has_and_belongs_to_many :posts_grouped_by_title, -> { group("title").select("title") }, :class_name => "Post"
def self.what_are_you
- 'a category...'
+ "a category..."
end
has_many :categorizations
@@ -26,9 +26,9 @@ class Category < ActiveRecord::Base
has_many :post_comments, :through => :posts, :source => :comments
has_many :authors, :through => :categorizations
- has_many :authors_with_select, -> { select 'authors.*, categorizations.post_id' }, :through => :categorizations, :source => :author
+ has_many :authors_with_select, -> { select "authors.*, categorizations.post_id" }, :through => :categorizations, :source => :author
- scope :general, -> { where(:name => 'General') }
+ scope :general, -> { where(:name => "General") }
end
class SpecialCategory < Category
diff --git a/activerecord/test/models/club.rb b/activerecord/test/models/club.rb
index 6ceafe5858..e1b3e706f2 100644
--- a/activerecord/test/models/club.rb
+++ b/activerecord/test/models/club.rb
@@ -18,6 +18,6 @@ end
class SuperClub < ActiveRecord::Base
self.table_name = "clubs"
- has_many :memberships, class_name: 'SuperMembership', foreign_key: 'club_id'
+ has_many :memberships, class_name: "SuperMembership", foreign_key: "club_id"
has_many :members, through: :memberships
end
diff --git a/activerecord/test/models/college.rb b/activerecord/test/models/college.rb
index 501af4a8dd..c9dbe1ecc2 100644
--- a/activerecord/test/models/college.rb
+++ b/activerecord/test/models/college.rb
@@ -1,5 +1,5 @@
-require_dependency 'models/arunit2_model'
-require 'active_support/core_ext/object/with_options'
+require_dependency "models/arunit2_model"
+require "active_support/core_ext/object/with_options"
class College < ARUnit2Model
has_many :courses
diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb
index dcc5c5a310..45463b69f2 100644
--- a/activerecord/test/models/comment.rb
+++ b/activerecord/test/models/comment.rb
@@ -16,11 +16,11 @@ class Comment < ActiveRecord::Base
belongs_to :first_post, :foreign_key => :post_id
belongs_to :special_post_with_default_scope, foreign_key: :post_id
- has_many :children, :class_name => 'Comment', :foreign_key => :parent_id
- belongs_to :parent, :class_name => 'Comment', :counter_cache => :children_count
+ has_many :children, :class_name => "Comment", :foreign_key => :parent_id
+ belongs_to :parent, :class_name => "Comment", :counter_cache => :children_count
def self.what_are_you
- 'a comment...'
+ "a comment..."
end
def self.search_by_type(q)
@@ -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/company.rb b/activerecord/test/models/company.rb
index 1dcd9fc21e..6a01dae18d 100644
--- a/activerecord/test/models/company.rb
+++ b/activerecord/test/models/company.rb
@@ -13,7 +13,7 @@ class Company < AbstractCompany
scope :of_first_firm, lambda {
joins(:account => :firm).
- where('firms.id' => 1)
+ where("firms.id" => 1)
}
def arbitrary_method
@@ -35,7 +35,7 @@ module Namespaced
end
class Firm < ::Company
- has_many :clients, :class_name => 'Namespaced::Client'
+ has_many :clients, :class_name => "Namespaced::Client"
end
class Client < ::Company
@@ -57,33 +57,33 @@ class Firm < Company
has_many :limited_clients, -> { limit 1 }, :class_name => "Client"
has_many :clients_with_interpolated_conditions, ->(firm) { where "rating > #{firm.rating}" }, :class_name => "Client"
has_many :clients_like_ms, -> { where("name = 'Microsoft'").order("id") }, :class_name => "Client"
- has_many :clients_like_ms_with_hash_conditions, -> { where(:name => 'Microsoft').order("id") }, :class_name => "Client"
- has_many :plain_clients, :class_name => 'Client'
- has_many :clients_using_primary_key, :class_name => 'Client',
- :primary_key => 'name', :foreign_key => 'firm_name'
- has_many :clients_using_primary_key_with_delete_all, :class_name => 'Client',
- :primary_key => 'name', :foreign_key => 'firm_name', :dependent => :delete_all
+ has_many :clients_like_ms_with_hash_conditions, -> { where(:name => "Microsoft").order("id") }, :class_name => "Client"
+ has_many :plain_clients, :class_name => "Client"
+ has_many :clients_using_primary_key, :class_name => "Client",
+ :primary_key => "name", :foreign_key => "firm_name"
+ has_many :clients_using_primary_key_with_delete_all, :class_name => "Client",
+ :primary_key => "name", :foreign_key => "firm_name", :dependent => :delete_all
has_many :clients_grouped_by_firm_id, -> { group("firm_id").select("firm_id") }, :class_name => "Client"
has_many :clients_grouped_by_name, -> { group("name").select("name") }, :class_name => "Client"
has_one :account, :foreign_key => "firm_id", :dependent => :destroy, :validate => true
- has_one :unvalidated_account, :foreign_key => "firm_id", :class_name => 'Account', :validate => false
- has_one :account_with_select, -> { select("id, firm_id") }, :foreign_key => "firm_id", :class_name=>'Account'
+ has_one :unvalidated_account, :foreign_key => "firm_id", :class_name => "Account", :validate => false
+ has_one :account_with_select, -> { select("id, firm_id") }, :foreign_key => "firm_id", :class_name=>"Account"
has_one :readonly_account, -> { readonly }, :foreign_key => "firm_id", :class_name => "Account"
# added order by id as in fixtures there are two accounts for Rails Core
# Oracle tests were failing because of that as the second fixture was selected
- has_one :account_using_primary_key, -> { order('id') }, :primary_key => "firm_id", :class_name => "Account"
+ has_one :account_using_primary_key, -> { order("id") }, :primary_key => "firm_id", :class_name => "Account"
has_one :account_using_foreign_and_primary_keys, :foreign_key => "firm_name", :primary_key => "name", :class_name => "Account"
- has_one :account_with_inexistent_foreign_key, class_name: 'Account', foreign_key: "inexistent"
+ has_one :account_with_inexistent_foreign_key, class_name: "Account", foreign_key: "inexistent"
has_one :deletable_account, :foreign_key => "firm_id", :class_name => "Account", :dependent => :delete
has_one :account_limit_500_with_hash_conditions, -> { where :credit_limit => 500 }, :foreign_key => "firm_id", :class_name => "Account"
- has_one :unautosaved_account, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false
+ has_one :unautosaved_account, :foreign_key => "firm_id", :class_name => "Account", :autosave => false
has_many :accounts
- has_many :unautosaved_accounts, :foreign_key => "firm_id", :class_name => 'Account', :autosave => false
+ has_many :unautosaved_accounts, :foreign_key => "firm_id", :class_name => "Account", :autosave => false
- has_many :association_with_references, -> { references(:foo) }, :class_name => 'Client'
+ has_many :association_with_references, -> { references(:foo) }, :class_name => "Client"
has_one :lead_developer, class_name: "Developer"
has_many :projects
@@ -104,18 +104,18 @@ end
class DependentFirm < Company
has_one :account, :foreign_key => "firm_id", :dependent => :nullify
- has_many :companies, :foreign_key => 'client_of', :dependent => :nullify
- has_one :company, :foreign_key => 'client_of', :dependent => :nullify
+ has_many :companies, :foreign_key => "client_of", :dependent => :nullify
+ has_one :company, :foreign_key => "client_of", :dependent => :nullify
end
class RestrictedWithExceptionFirm < Company
has_one :account, -> { order("id") }, :foreign_key => "firm_id", :dependent => :restrict_with_exception
- has_many :companies, -> { order("id") }, :foreign_key => 'client_of', :dependent => :restrict_with_exception
+ has_many :companies, -> { order("id") }, :foreign_key => "client_of", :dependent => :restrict_with_exception
end
class RestrictedWithErrorFirm < Company
has_one :account, -> { order("id") }, :foreign_key => "firm_id", :dependent => :restrict_with_error
- has_many :companies, -> { order("id") }, :foreign_key => 'client_of', :dependent => :restrict_with_error
+ has_many :companies, -> { order("id") }, :foreign_key => "client_of", :dependent => :restrict_with_error
end
class Client < Company
@@ -183,7 +183,7 @@ end
class ExclusivelyDependentFirm < Company
has_one :account, :foreign_key => "firm_id", :dependent => :delete
has_many :dependent_sanitized_conditional_clients_of_firm, -> { order("id").where("name = 'BigShot Inc.'") }, :foreign_key => "client_of", :class_name => "Client", :dependent => :delete_all
- has_many :dependent_conditional_clients_of_firm, -> { order("id").where("name = ?", 'BigShot Inc.') }, :foreign_key => "client_of", :class_name => "Client", :dependent => :delete_all
+ has_many :dependent_conditional_clients_of_firm, -> { order("id").where("name = ?", "BigShot Inc.") }, :foreign_key => "client_of", :class_name => "Client", :dependent => :delete_all
end
class SpecialClient < Client
@@ -193,7 +193,7 @@ class VerySpecialClient < SpecialClient
end
class Account < ActiveRecord::Base
- belongs_to :firm, :class_name => 'Company'
+ belongs_to :firm, :class_name => "Company"
belongs_to :unautosaved_firm, :foreign_key => "firm_id", :class_name => "Firm", :autosave => false
alias_attribute :available_credit, :credit_limit
@@ -204,7 +204,7 @@ class Account < ActiveRecord::Base
# Test private kernel method through collection proxy using has_many.
def self.open
- where('firm_name = ?', '37signals')
+ where("firm_name = ?", "37signals")
end
before_destroy do |account|
diff --git a/activerecord/test/models/company_in_module.rb b/activerecord/test/models/company_in_module.rb
index bf0a0d1c3e..b444f9c49c 100644
--- a/activerecord/test/models/company_in_module.rb
+++ b/activerecord/test/models/company_in_module.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/object/with_options'
+require "active_support/core_ext/object/with_options"
module MyApplication
module Business
@@ -10,7 +10,7 @@ module MyApplication
has_many :clients_sorted_desc, -> { order("id DESC") }, :class_name => "Client"
has_many :clients_of_firm, -> { order "id" }, :foreign_key => "client_of", :class_name => "Client"
has_many :clients_like_ms, -> { where("name = 'Microsoft'").order("id") }, :class_name => "Client"
- has_one :account, :class_name => 'MyApplication::Billing::Account', :dependent => :destroy
+ has_one :account, :class_name => "MyApplication::Billing::Account", :dependent => :destroy
end
class Client < Company
@@ -31,14 +31,14 @@ module MyApplication
module Prefixed
def self.table_name_prefix
- 'prefixed_'
+ "prefixed_"
end
class Company < ActiveRecord::Base
end
class Firm < Company
- self.table_name = 'companies'
+ self.table_name = "companies"
end
module Nested
@@ -49,14 +49,14 @@ module MyApplication
module Suffixed
def self.table_name_suffix
- '_suffixed'
+ "_suffixed"
end
class Company < ActiveRecord::Base
end
class Firm < Company
- self.table_name = 'companies'
+ self.table_name = "companies"
end
module Nested
@@ -68,22 +68,22 @@ module MyApplication
module Billing
class Firm < ActiveRecord::Base
- self.table_name = 'companies'
+ self.table_name = "companies"
end
module Nested
class Firm < ActiveRecord::Base
- self.table_name = 'companies'
+ self.table_name = "companies"
end
end
class Account < ActiveRecord::Base
with_options(:foreign_key => :firm_id) do |i|
- i.belongs_to :firm, :class_name => 'MyApplication::Business::Firm'
- i.belongs_to :qualified_billing_firm, :class_name => 'MyApplication::Billing::Firm'
- i.belongs_to :unqualified_billing_firm, :class_name => 'Firm'
- i.belongs_to :nested_qualified_billing_firm, :class_name => 'MyApplication::Billing::Nested::Firm'
- i.belongs_to :nested_unqualified_billing_firm, :class_name => 'Nested::Firm'
+ i.belongs_to :firm, :class_name => "MyApplication::Business::Firm"
+ i.belongs_to :qualified_billing_firm, :class_name => "MyApplication::Billing::Firm"
+ i.belongs_to :unqualified_billing_firm, :class_name => "Firm"
+ i.belongs_to :nested_qualified_billing_firm, :class_name => "MyApplication::Billing::Nested::Firm"
+ i.belongs_to :nested_unqualified_billing_firm, :class_name => "Nested::Firm"
end
validate :check_empty_credit_limit
diff --git a/activerecord/test/models/computer.rb b/activerecord/test/models/computer.rb
index cc8deb1b2b..0295ff9736 100644
--- a/activerecord/test/models/computer.rb
+++ b/activerecord/test/models/computer.rb
@@ -1,3 +1,3 @@
class Computer < ActiveRecord::Base
- belongs_to :developer, :foreign_key=>'developer'
+ belongs_to :developer, :foreign_key=>"developer"
end
diff --git a/activerecord/test/models/contact.rb b/activerecord/test/models/contact.rb
index 9f2f69e1ee..15e3832204 100644
--- a/activerecord/test/models/contact.rb
+++ b/activerecord/test/models/contact.rb
@@ -1,11 +1,11 @@
module ContactFakeColumns
def self.extended(base)
base.class_eval do
- establish_connection(:adapter => 'fake')
+ establish_connection(:adapter => "fake")
connection.data_sources = [table_name]
connection.primary_keys = {
- table_name => 'id'
+ table_name => "id"
}
column :id, :integer
@@ -19,7 +19,7 @@ module ContactFakeColumns
serialize :preferences
- belongs_to :alternative, :class_name => 'Contact'
+ belongs_to :alternative, :class_name => "Contact"
end
end
@@ -37,5 +37,5 @@ class ContactSti < ActiveRecord::Base
extend ContactFakeColumns
column :type, :string
- def type; 'ContactSti' end
+ def type; "ContactSti" end
end
diff --git a/activerecord/test/models/content.rb b/activerecord/test/models/content.rb
index 140e1dfc78..68db2127d8 100644
--- a/activerecord/test/models/content.rb
+++ b/activerecord/test/models/content.rb
@@ -1,5 +1,5 @@
class Content < ActiveRecord::Base
- self.table_name = 'content'
+ self.table_name = "content"
has_one :content_position, dependent: :destroy
def self.destroyed_ids
@@ -12,8 +12,8 @@ class Content < ActiveRecord::Base
end
class ContentWhichRequiresTwoDestroyCalls < ActiveRecord::Base
- self.table_name = 'content'
- has_one :content_position, foreign_key: 'content_id', dependent: :destroy
+ self.table_name = "content"
+ has_one :content_position, foreign_key: "content_id", dependent: :destroy
after_initialize do
@destroy_count = 0
diff --git a/activerecord/test/models/contract.rb b/activerecord/test/models/contract.rb
index cdf7b267b5..e16758498f 100644
--- a/activerecord/test/models/contract.rb
+++ b/activerecord/test/models/contract.rb
@@ -1,7 +1,7 @@
class Contract < ActiveRecord::Base
belongs_to :company
belongs_to :developer
- belongs_to :firm, :foreign_key => 'company_id'
+ belongs_to :firm, :foreign_key => "company_id"
before_save :hi
after_save :bye
diff --git a/activerecord/test/models/course.rb b/activerecord/test/models/course.rb
index f3d0e05ff7..348f2bf1e0 100644
--- a/activerecord/test/models/course.rb
+++ b/activerecord/test/models/course.rb
@@ -1,4 +1,4 @@
-require_dependency 'models/arunit2_model'
+require_dependency "models/arunit2_model"
class Course < ARUnit2Model
belongs_to :college
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb
index 9a907273f8..41cbe35cb4 100644
--- a/activerecord/test/models/developer.rb
+++ b/activerecord/test/models/developer.rb
@@ -1,4 +1,4 @@
-require 'ostruct'
+require "ostruct"
module DeveloperProjectsAssociationExtension2
def find_least_recent
@@ -43,11 +43,11 @@ class Developer < ActiveRecord::Base
end
end
- has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'
+ has_and_belongs_to_many :special_projects, :join_table => "developers_projects", :association_foreign_key => "project_id"
has_and_belongs_to_many :sym_special_projects,
:join_table => :developers_projects,
- :association_foreign_key => 'project_id',
- :class_name => 'SpecialProject'
+ :association_foreign_key => "project_id",
+ :class_name => "SpecialProject"
has_many :audit_logs
has_many :contracts
@@ -59,7 +59,7 @@ class Developer < ActiveRecord::Base
belongs_to :firm
has_many :contracted_projects, class_name: "Project"
- scope :jamises, -> { where(:name => 'Jamis') }
+ scope :jamises, -> { where(:name => "Jamis") }
validates_inclusion_of :salary, :in => 50000..200000
validates_length_of :name, :within => 3..20
@@ -69,7 +69,7 @@ class Developer < ActiveRecord::Base
end
attr_accessor :last_name
- define_attribute_method 'last_name'
+ define_attribute_method "last_name"
def log=(message)
audit_logs.build :message => message
@@ -88,12 +88,12 @@ end
class AuditLog < ActiveRecord::Base
belongs_to :developer, :validate => true
- belongs_to :unvalidated_developer, :class_name => 'Developer'
+ belongs_to :unvalidated_developer, :class_name => "Developer"
end
class DeveloperWithBeforeDestroyRaise < ActiveRecord::Base
- self.table_name = 'developers'
- has_and_belongs_to_many :projects, :join_table => 'developers_projects', :foreign_key => 'developer_id'
+ self.table_name = "developers"
+ has_and_belongs_to_many :projects, :join_table => "developers_projects", :foreign_key => "developer_id"
before_destroy :raise_if_projects_empty!
def raise_if_projects_empty!
@@ -102,63 +102,63 @@ class DeveloperWithBeforeDestroyRaise < ActiveRecord::Base
end
class DeveloperWithSelect < ActiveRecord::Base
- self.table_name = 'developers'
- default_scope { select('name') }
+ self.table_name = "developers"
+ default_scope { select("name") }
end
class DeveloperWithIncludes < ActiveRecord::Base
- self.table_name = 'developers'
+ self.table_name = "developers"
has_many :audit_logs, :foreign_key => :developer_id
default_scope { includes(:audit_logs) }
end
class DeveloperFilteredOnJoins < ActiveRecord::Base
- self.table_name = 'developers'
- has_and_belongs_to_many :projects, -> { order('projects.id') }, :foreign_key => 'developer_id', :join_table => 'developers_projects'
+ self.table_name = "developers"
+ has_and_belongs_to_many :projects, -> { order("projects.id") }, :foreign_key => "developer_id", :join_table => "developers_projects"
def self.default_scope
- joins(:projects).where(:projects => { :name => 'Active Controller' })
+ joins(:projects).where(:projects => { :name => "Active Controller" })
end
end
class DeveloperOrderedBySalary < ActiveRecord::Base
- self.table_name = 'developers'
- default_scope { order('salary DESC') }
+ self.table_name = "developers"
+ default_scope { order("salary DESC") }
- scope :by_name, -> { order('name DESC') }
+ scope :by_name, -> { order("name DESC") }
end
class DeveloperCalledDavid < ActiveRecord::Base
- self.table_name = 'developers'
+ self.table_name = "developers"
default_scope { where("name = 'David'") }
end
class LazyLambdaDeveloperCalledDavid < ActiveRecord::Base
- self.table_name = 'developers'
- default_scope lambda { where(:name => 'David') }
+ self.table_name = "developers"
+ default_scope lambda { where(:name => "David") }
end
class LazyBlockDeveloperCalledDavid < ActiveRecord::Base
- self.table_name = 'developers'
- default_scope { where(:name => 'David') }
+ self.table_name = "developers"
+ default_scope { where(:name => "David") }
end
class CallableDeveloperCalledDavid < ActiveRecord::Base
- self.table_name = 'developers'
- default_scope OpenStruct.new(:call => where(:name => 'David'))
+ self.table_name = "developers"
+ default_scope OpenStruct.new(:call => where(:name => "David"))
end
class ClassMethodDeveloperCalledDavid < ActiveRecord::Base
- self.table_name = 'developers'
+ self.table_name = "developers"
def self.default_scope
- where(:name => 'David')
+ where(:name => "David")
end
end
class ClassMethodReferencingScopeDeveloperCalledDavid < ActiveRecord::Base
- self.table_name = 'developers'
- scope :david, -> { where(:name => 'David') }
+ self.table_name = "developers"
+ scope :david, -> { where(:name => "David") }
def self.default_scope
david
@@ -166,36 +166,36 @@ class ClassMethodReferencingScopeDeveloperCalledDavid < ActiveRecord::Base
end
class LazyBlockReferencingScopeDeveloperCalledDavid < ActiveRecord::Base
- self.table_name = 'developers'
- scope :david, -> { where(:name => 'David') }
+ self.table_name = "developers"
+ scope :david, -> { where(:name => "David") }
default_scope { david }
end
class DeveloperCalledJamis < ActiveRecord::Base
- self.table_name = 'developers'
+ self.table_name = "developers"
- default_scope { where(:name => 'Jamis') }
- scope :poor, -> { where('salary < 150000') }
+ default_scope { where(:name => "Jamis") }
+ scope :poor, -> { where("salary < 150000") }
scope :david, -> { where name: "David" }
scope :david2, -> { unscoped.where name: "David" }
end
class PoorDeveloperCalledJamis < ActiveRecord::Base
- self.table_name = 'developers'
+ self.table_name = "developers"
- default_scope -> { where(:name => 'Jamis', :salary => 50000) }
+ default_scope -> { where(:name => "Jamis", :salary => 50000) }
end
class InheritedPoorDeveloperCalledJamis < DeveloperCalledJamis
- self.table_name = 'developers'
+ self.table_name = "developers"
default_scope -> { where(:salary => 50000) }
end
class MultiplePoorDeveloperCalledJamis < ActiveRecord::Base
- self.table_name = 'developers'
+ self.table_name = "developers"
- default_scope -> { where(:name => 'Jamis') }
+ default_scope -> { where(:name => "Jamis") }
default_scope -> { where(:salary => 50000) }
end
@@ -206,21 +206,21 @@ module SalaryDefaultScope
end
class ModuleIncludedPoorDeveloperCalledJamis < DeveloperCalledJamis
- self.table_name = 'developers'
+ self.table_name = "developers"
include SalaryDefaultScope
end
class EagerDeveloperWithDefaultScope < ActiveRecord::Base
- self.table_name = 'developers'
- has_and_belongs_to_many :projects, -> { order('projects.id') }, :foreign_key => 'developer_id', :join_table => 'developers_projects'
+ self.table_name = "developers"
+ has_and_belongs_to_many :projects, -> { order("projects.id") }, :foreign_key => "developer_id", :join_table => "developers_projects"
default_scope { includes(:projects) }
end
class EagerDeveloperWithClassMethodDefaultScope < ActiveRecord::Base
- self.table_name = 'developers'
- has_and_belongs_to_many :projects, -> { order('projects.id') }, :foreign_key => 'developer_id', :join_table => 'developers_projects'
+ self.table_name = "developers"
+ has_and_belongs_to_many :projects, -> { order("projects.id") }, :foreign_key => "developer_id", :join_table => "developers_projects"
def self.default_scope
includes(:projects)
@@ -228,28 +228,28 @@ class EagerDeveloperWithClassMethodDefaultScope < ActiveRecord::Base
end
class EagerDeveloperWithLambdaDefaultScope < ActiveRecord::Base
- self.table_name = 'developers'
- has_and_belongs_to_many :projects, -> { order('projects.id') }, :foreign_key => 'developer_id', :join_table => 'developers_projects'
+ self.table_name = "developers"
+ has_and_belongs_to_many :projects, -> { order("projects.id") }, :foreign_key => "developer_id", :join_table => "developers_projects"
default_scope lambda { includes(:projects) }
end
class EagerDeveloperWithBlockDefaultScope < ActiveRecord::Base
- self.table_name = 'developers'
- has_and_belongs_to_many :projects, -> { order('projects.id') }, :foreign_key => 'developer_id', :join_table => 'developers_projects'
+ self.table_name = "developers"
+ has_and_belongs_to_many :projects, -> { order("projects.id") }, :foreign_key => "developer_id", :join_table => "developers_projects"
default_scope { includes(:projects) }
end
class EagerDeveloperWithCallableDefaultScope < ActiveRecord::Base
- self.table_name = 'developers'
- has_and_belongs_to_many :projects, -> { order('projects.id') }, :foreign_key => 'developer_id', :join_table => 'developers_projects'
+ self.table_name = "developers"
+ has_and_belongs_to_many :projects, -> { order("projects.id") }, :foreign_key => "developer_id", :join_table => "developers_projects"
default_scope OpenStruct.new(:call => includes(:projects))
end
class ThreadsafeDeveloper < ActiveRecord::Base
- self.table_name = 'developers'
+ self.table_name = "developers"
def self.default_scope
sleep 0.05 if Thread.current[:long_default_scope]
diff --git a/activerecord/test/models/doubloon.rb b/activerecord/test/models/doubloon.rb
index 2b11d128e2..7272504666 100644
--- a/activerecord/test/models/doubloon.rb
+++ b/activerecord/test/models/doubloon.rb
@@ -8,5 +8,5 @@ end
class Doubloon < AbstractDoubloon
# This uses an abstract class that defines attributes and associations.
- self.table_name = 'doubloons'
+ self.table_name = "doubloons"
end
diff --git a/activerecord/test/models/edge.rb b/activerecord/test/models/edge.rb
index 55e0c31fcb..1de4756b28 100644
--- a/activerecord/test/models/edge.rb
+++ b/activerecord/test/models/edge.rb
@@ -1,5 +1,5 @@
# This class models an edge in a directed graph.
class Edge < ActiveRecord::Base
- belongs_to :source, :class_name => 'Vertex', :foreign_key => 'source_id'
- belongs_to :sink, :class_name => 'Vertex', :foreign_key => 'sink_id'
+ belongs_to :source, :class_name => "Vertex", :foreign_key => "source_id"
+ belongs_to :sink, :class_name => "Vertex", :foreign_key => "sink_id"
end
diff --git a/activerecord/test/models/engine.rb b/activerecord/test/models/engine.rb
index 851ff8c22b..c30502e3ea 100644
--- a/activerecord/test/models/engine.rb
+++ b/activerecord/test/models/engine.rb
@@ -1,4 +1,4 @@
class Engine < ActiveRecord::Base
- belongs_to :my_car, :class_name => 'Car', :foreign_key => 'car_id', :counter_cache => :engines_count
+ belongs_to :my_car, :class_name => "Car", :foreign_key => "car_id", :counter_cache => :engines_count
end
diff --git a/activerecord/test/models/face.rb b/activerecord/test/models/face.rb
index af76fea52c..5f33372b16 100644
--- a/activerecord/test/models/face.rb
+++ b/activerecord/test/models/face.rb
@@ -4,6 +4,6 @@ class Face < ActiveRecord::Base
# Oracle identifier length is limited to 30 bytes or less, `polymorphic` renamed `poly`
belongs_to :poly_man_without_inverse, :polymorphic => true
# These is a "broken" inverse_of for the purposes of testing
- belongs_to :horrible_man, :class_name => 'Man', :inverse_of => :horrible_face
+ belongs_to :horrible_man, :class_name => "Man", :inverse_of => :horrible_face
belongs_to :horrible_polymorphic_man, :polymorphic => true, :inverse_of => :horrible_polymorphic_face
end
diff --git a/activerecord/test/models/friendship.rb b/activerecord/test/models/friendship.rb
index 4b411ca8e0..578382b494 100644
--- a/activerecord/test/models/friendship.rb
+++ b/activerecord/test/models/friendship.rb
@@ -1,6 +1,6 @@
class Friendship < ActiveRecord::Base
- belongs_to :friend, class_name: 'Person'
+ belongs_to :friend, class_name: "Person"
# friend_too exists to test a bug, and probably shouldn't be used elsewhere
- belongs_to :friend_too, foreign_key: 'friend_id', class_name: 'Person', counter_cache: :friends_too_count
- belongs_to :follower, class_name: 'Person'
+ belongs_to :friend_too, foreign_key: "friend_id", class_name: "Person", counter_cache: :friends_too_count
+ belongs_to :follower, class_name: "Person"
end
diff --git a/activerecord/test/models/hotel.rb b/activerecord/test/models/hotel.rb
index 9c90ffcff4..203e384c76 100644
--- a/activerecord/test/models/hotel.rb
+++ b/activerecord/test/models/hotel.rb
@@ -1,8 +1,8 @@
class Hotel < ActiveRecord::Base
has_many :departments
has_many :chefs, through: :departments
- has_many :cake_designers, source_type: 'CakeDesigner', source: :employable, through: :chefs
- has_many :drink_designers, source_type: 'DrinkDesigner', source: :employable, through: :chefs
+ has_many :cake_designers, source_type: "CakeDesigner", source: :employable, through: :chefs
+ has_many :drink_designers, source_type: "DrinkDesigner", source: :employable, through: :chefs
has_many :chef_lists, as: :employable_list
has_many :mocktail_designers, through: :chef_lists, source: :employable, :source_type => "MocktailDesigner"
diff --git a/activerecord/test/models/job.rb b/activerecord/test/models/job.rb
index f7b0e787b1..267f73bd6f 100644
--- a/activerecord/test/models/job.rb
+++ b/activerecord/test/models/job.rb
@@ -1,7 +1,7 @@
class Job < ActiveRecord::Base
has_many :references
has_many :people, :through => :references
- belongs_to :ideal_reference, :class_name => 'Reference'
+ belongs_to :ideal_reference, :class_name => "Reference"
has_many :agents, :through => :people
end
diff --git a/activerecord/test/models/joke.rb b/activerecord/test/models/joke.rb
index edda4655dc..eeb5818a1f 100644
--- a/activerecord/test/models/joke.rb
+++ b/activerecord/test/models/joke.rb
@@ -1,7 +1,7 @@
class Joke < ActiveRecord::Base
- self.table_name = 'funny_jokes'
+ self.table_name = "funny_jokes"
end
class GoodJoke < ActiveRecord::Base
- self.table_name = 'funny_jokes'
+ self.table_name = "funny_jokes"
end
diff --git a/activerecord/test/models/keyboard.rb b/activerecord/test/models/keyboard.rb
index 39347e274e..bcede53ec9 100644
--- a/activerecord/test/models/keyboard.rb
+++ b/activerecord/test/models/keyboard.rb
@@ -1,3 +1,3 @@
class Keyboard < ActiveRecord::Base
- self.primary_key = 'key_number'
+ self.primary_key = "key_number"
end
diff --git a/activerecord/test/models/man.rb b/activerecord/test/models/man.rb
index 4fbb6b226b..797c46dcbe 100644
--- a/activerecord/test/models/man.rb
+++ b/activerecord/test/models/man.rb
@@ -1,11 +1,11 @@
class Man < ActiveRecord::Base
has_one :face, :inverse_of => :man
- has_one :polymorphic_face, :class_name => 'Face', :as => :polymorphic_man, :inverse_of => :polymorphic_man
- has_one :polymorphic_face_without_inverse, :class_name => 'Face', :as => :poly_man_without_inverse
+ has_one :polymorphic_face, :class_name => "Face", :as => :polymorphic_man, :inverse_of => :polymorphic_man
+ has_one :polymorphic_face_without_inverse, :class_name => "Face", :as => :poly_man_without_inverse
has_many :interests, :inverse_of => :man
- has_many :polymorphic_interests, :class_name => 'Interest', :as => :polymorphic_man, :inverse_of => :polymorphic_man
+ has_many :polymorphic_interests, :class_name => "Interest", :as => :polymorphic_man, :inverse_of => :polymorphic_man
# These are "broken" inverse_of associations for the purposes of testing
- has_one :dirty_face, :class_name => 'Face', :inverse_of => :dirty_man
- has_many :secret_interests, :class_name => 'Interest', :inverse_of => :secret_man
+ has_one :dirty_face, :class_name => "Face", :inverse_of => :dirty_man
+ has_many :secret_interests, :class_name => "Interest", :inverse_of => :secret_man
has_one :mixed_case_monkey
end
diff --git a/activerecord/test/models/matey.rb b/activerecord/test/models/matey.rb
index 47b0baa974..1badaede0a 100644
--- a/activerecord/test/models/matey.rb
+++ b/activerecord/test/models/matey.rb
@@ -1,4 +1,4 @@
class Matey < ActiveRecord::Base
belongs_to :pirate
- belongs_to :target, :class_name => 'Pirate'
+ belongs_to :target, :class_name => "Pirate"
end
diff --git a/activerecord/test/models/member.rb b/activerecord/test/models/member.rb
index 7693c6e515..dd90d3e92b 100644
--- a/activerecord/test/models/member.rb
+++ b/activerecord/test/models/member.rb
@@ -27,7 +27,7 @@ class Member < ActiveRecord::Base
has_many :clubs, :through => :current_memberships
has_many :tenant_memberships
- has_many :tenant_clubs, through: :tenant_memberships, class_name: 'Club', source: :club
+ has_many :tenant_clubs, through: :tenant_memberships, class_name: "Club", source: :club
has_one :club_through_many, :through => :current_memberships, :source => :club
diff --git a/activerecord/test/models/membership.rb b/activerecord/test/models/membership.rb
index e181ba1f11..2c3ad230a7 100644
--- a/activerecord/test/models/membership.rb
+++ b/activerecord/test/models/membership.rb
@@ -9,7 +9,7 @@ class CurrentMembership < Membership
end
class SuperMembership < Membership
- belongs_to :member, -> { order('members.id DESC') }
+ belongs_to :member, -> { order("members.id DESC") }
belongs_to :club
end
diff --git a/activerecord/test/models/node.rb b/activerecord/test/models/node.rb
index 07dd2dbccb..459ea8cf95 100644
--- a/activerecord/test/models/node.rb
+++ b/activerecord/test/models/node.rb
@@ -1,5 +1,5 @@
class Node < ActiveRecord::Base
belongs_to :tree, touch: true
- belongs_to :parent, class_name: 'Node', touch: true, optional: true
- has_many :children, class_name: 'Node', foreign_key: :parent_id, dependent: :destroy
+ belongs_to :parent, class_name: "Node", touch: true, optional: true
+ has_many :children, class_name: "Node", foreign_key: :parent_id, dependent: :destroy
end
diff --git a/activerecord/test/models/order.rb b/activerecord/test/models/order.rb
index e838c0b70d..4ec7198c88 100644
--- a/activerecord/test/models/order.rb
+++ b/activerecord/test/models/order.rb
@@ -1,4 +1,4 @@
class Order < ActiveRecord::Base
- belongs_to :billing, :class_name => 'Customer', :foreign_key => 'billing_customer_id'
- belongs_to :shipping, :class_name => 'Customer', :foreign_key => 'shipping_customer_id'
+ belongs_to :billing, :class_name => "Customer", :foreign_key => "billing_customer_id"
+ belongs_to :shipping, :class_name => "Customer", :foreign_key => "shipping_customer_id"
end
diff --git a/activerecord/test/models/organization.rb b/activerecord/test/models/organization.rb
index f3e92f3067..1858351dd1 100644
--- a/activerecord/test/models/organization.rb
+++ b/activerecord/test/models/organization.rb
@@ -10,5 +10,5 @@ class Organization < ActiveRecord::Base
has_many :posts, :through => :author, :source => :posts
- scope :clubs, -> { from('clubs') }
+ scope :clubs, -> { from("clubs") }
end
diff --git a/activerecord/test/models/owner.rb b/activerecord/test/models/owner.rb
index ce8242cf2f..45508a7f67 100644
--- a/activerecord/test/models/owner.rb
+++ b/activerecord/test/models/owner.rb
@@ -1,10 +1,10 @@
class Owner < ActiveRecord::Base
self.primary_key = :owner_id
- has_many :pets, -> { order 'pets.name desc' }
+ has_many :pets, -> { order "pets.name desc" }
has_many :toys, through: :pets
has_many :persons, through: :pets
- belongs_to :last_pet, class_name: 'Pet'
+ belongs_to :last_pet, class_name: "Pet"
scope :including_last_pet, -> {
select(%q[
owners.*, (
diff --git a/activerecord/test/models/parrot.rb b/activerecord/test/models/parrot.rb
index ddc9dcaf29..9ee9670da9 100644
--- a/activerecord/test/models/parrot.rb
+++ b/activerecord/test/models/parrot.rb
@@ -19,5 +19,5 @@ class LiveParrot < Parrot
end
class DeadParrot < Parrot
- belongs_to :killer, :class_name => 'Pirate', foreign_key: :killer_id
+ belongs_to :killer, :class_name => "Pirate", foreign_key: :killer_id
end
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb
index a4a9c6b0d4..a33b4dca6b 100644
--- a/activerecord/test/models/person.rb
+++ b/activerecord/test/models/person.rb
@@ -5,19 +5,19 @@ class Person < ActiveRecord::Base
has_many :posts, :through => :readers
has_many :secure_posts, :through => :secure_readers
- has_many :posts_with_no_comments, -> { includes(:comments).where('comments.id is null').references(:comments) },
+ has_many :posts_with_no_comments, -> { includes(:comments).where("comments.id is null").references(:comments) },
:through => :readers, :source => :post
- has_many :friendships, foreign_key: 'friend_id'
+ has_many :friendships, foreign_key: "friend_id"
# friends_too exists to test a bug, and probably shouldn't be used elsewhere
- has_many :friends_too, foreign_key: 'friend_id', class_name: 'Friendship'
+ has_many :friends_too, foreign_key: "friend_id", class_name: "Friendship"
has_many :followers, through: :friendships
has_many :references
has_many :bad_references
- has_many :fixed_bad_references, -> { where :favourite => true }, :class_name => 'BadReference'
- has_one :favourite_reference, -> { where 'favourite=?', true }, :class_name => 'Reference'
- has_many :posts_with_comments_sorted_by_comment_id, -> { includes(:comments).order('comments.id') }, :through => :readers, :source => :post
+ has_many :fixed_bad_references, -> { where :favourite => true }, :class_name => "BadReference"
+ has_one :favourite_reference, -> { where "favourite=?", true }, :class_name => "Reference"
+ has_many :posts_with_comments_sorted_by_comment_id, -> { includes(:comments).order("comments.id") }, :through => :readers, :source => :post
has_many :first_posts, -> { where(id: [1, 2]) }, through: :readers
has_many :jobs, :through => :references
@@ -25,10 +25,10 @@ class Person < ActiveRecord::Base
has_many :jobs_with_dependent_delete_all, :source => :job, :through => :references, :dependent => :delete_all
has_many :jobs_with_dependent_nullify, :source => :job, :through => :references, :dependent => :nullify
- belongs_to :primary_contact, :class_name => 'Person'
- has_many :agents, :class_name => 'Person', :foreign_key => 'primary_contact_id'
+ belongs_to :primary_contact, :class_name => "Person"
+ has_many :agents, :class_name => "Person", :foreign_key => "primary_contact_id"
has_many :agents_of_agents, :through => :agents, :source => :agents
- belongs_to :number1_fan, :class_name => 'Person'
+ belongs_to :number1_fan, :class_name => "Person"
has_many :personal_legacy_things, :dependent => :destroy
@@ -36,25 +36,25 @@ class Person < ActiveRecord::Base
has_many :agents_posts_authors, :through => :agents_posts, :source => :author
has_many :essays, primary_key: "first_name", foreign_key: "writer_id"
- scope :males, -> { where(:gender => 'M') }
+ scope :males, -> { where(:gender => "M") }
end
class PersonWithDependentDestroyJobs < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
has_many :references, :foreign_key => :person_id
has_many :jobs, :source => :job, :through => :references, :dependent => :destroy
end
class PersonWithDependentDeleteAllJobs < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
has_many :references, :foreign_key => :person_id
has_many :jobs, :source => :job, :through => :references, :dependent => :delete_all
end
class PersonWithDependentNullifyJobs < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
has_many :references, :foreign_key => :person_id
has_many :jobs, :source => :job, :through => :references, :dependent => :nullify
@@ -62,12 +62,12 @@ end
class LoosePerson < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
self.abstract_class = true
- has_one :best_friend, :class_name => 'LoosePerson', :foreign_key => :best_friend_id
- belongs_to :best_friend_of, :class_name => 'LoosePerson', :foreign_key => :best_friend_of_id
- has_many :best_friends, :class_name => 'LoosePerson', :foreign_key => :best_friend_id
+ has_one :best_friend, :class_name => "LoosePerson", :foreign_key => :best_friend_id
+ belongs_to :best_friend_of, :class_name => "LoosePerson", :foreign_key => :best_friend_of_id
+ has_many :best_friends, :class_name => "LoosePerson", :foreign_key => :best_friend_id
accepts_nested_attributes_for :best_friend, :best_friend_of, :best_friends
end
@@ -75,11 +75,11 @@ end
class LooseDescendant < LoosePerson; end
class TightPerson < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
- has_one :best_friend, :class_name => 'TightPerson', :foreign_key => :best_friend_id
- belongs_to :best_friend_of, :class_name => 'TightPerson', :foreign_key => :best_friend_of_id
- has_many :best_friends, :class_name => 'TightPerson', :foreign_key => :best_friend_id
+ has_one :best_friend, :class_name => "TightPerson", :foreign_key => :best_friend_id
+ belongs_to :best_friend_of, :class_name => "TightPerson", :foreign_key => :best_friend_of_id
+ has_many :best_friends, :class_name => "TightPerson", :foreign_key => :best_friend_id
accepts_nested_attributes_for :best_friend, :best_friend_of, :best_friends
end
@@ -87,9 +87,9 @@ end
class TightDescendant < TightPerson; end
class RichPerson < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
- has_and_belongs_to_many :treasures, :join_table => 'peoples_treasures'
+ has_and_belongs_to_many :treasures, :join_table => "peoples_treasures"
before_validation :run_before_create, on: :create
before_validation :run_before_validation
@@ -97,18 +97,18 @@ class RichPerson < ActiveRecord::Base
private
def run_before_create
- self.first_name = first_name.to_s + 'run_before_create'
+ self.first_name = first_name.to_s + "run_before_create"
end
def run_before_validation
- self.first_name = first_name.to_s + 'run_before_validation'
+ self.first_name = first_name.to_s + "run_before_validation"
end
end
class NestedPerson < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
- has_one :best_friend, :class_name => 'NestedPerson', :foreign_key => :best_friend_id
+ has_one :best_friend, :class_name => "NestedPerson", :foreign_key => :best_friend_id
accepts_nested_attributes_for :best_friend, :update_only => true
def comments=(new_comments)
@@ -136,7 +136,7 @@ class Insure
end
class SerializedPerson < ActiveRecord::Base
- self.table_name = 'people'
+ self.table_name = "people"
serialize :insures, Insure
end
diff --git a/activerecord/test/models/pet.rb b/activerecord/test/models/pet.rb
index 53489fa1b3..06170837b6 100644
--- a/activerecord/test/models/pet.rb
+++ b/activerecord/test/models/pet.rb
@@ -6,7 +6,7 @@ class Pet < ActiveRecord::Base
has_many :toys
has_many :pet_treasures
has_many :treasures, through: :pet_treasures
- has_many :persons, through: :treasures, source: :looter, source_type: 'Person'
+ has_many :persons, through: :treasures, source: :looter, source_type: "Person"
class << self
attr_accessor :after_destroy_output
diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb
index 30545bdcd7..7cb602f445 100644
--- a/activerecord/test/models/pirate.rb
+++ b/activerecord/test/models/pirate.rb
@@ -1,8 +1,8 @@
class Pirate < ActiveRecord::Base
belongs_to :parrot, :validate => true
- belongs_to :non_validated_parrot, :class_name => 'Parrot'
- has_and_belongs_to_many :parrots, -> { order('parrots.id ASC') }, :validate => true
- has_and_belongs_to_many :non_validated_parrots, :class_name => 'Parrot'
+ belongs_to :non_validated_parrot, :class_name => "Parrot"
+ has_and_belongs_to_many :parrots, -> { order("parrots.id ASC") }, :validate => true
+ has_and_belongs_to_many :non_validated_parrots, :class_name => "Parrot"
has_and_belongs_to_many :parrots_with_method_callbacks, :class_name => "Parrot",
:before_add => :log_before_add,
:after_add => :log_after_add,
@@ -19,9 +19,9 @@ class Pirate < ActiveRecord::Base
has_many :treasure_estimates, :through => :treasures, :source => :price_estimates
has_one :ship
- has_one :update_only_ship, :class_name => 'Ship'
- has_one :non_validated_ship, :class_name => 'Ship'
- has_many :birds, -> { order('birds.id ASC') }
+ has_one :update_only_ship, :class_name => "Ship"
+ has_one :non_validated_ship, :class_name => "Ship"
+ has_many :birds, -> { order("birds.id ASC") }
has_many :birds_with_method_callbacks, :class_name => "Bird",
:before_add => :log_before_add,
:after_add => :log_after_add,
@@ -34,7 +34,7 @@ class Pirate < ActiveRecord::Base
: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"
+ has_one :foo_bulb, -> { where :name => "foo" }, :foreign_key => :car_id, :class_name => "Bulb"
accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc(&:empty?)
accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc(&:empty?)
@@ -50,7 +50,7 @@ class Pirate < ActiveRecord::Base
end
def reject_empty_ships_on_create(attributes)
- attributes.delete('_reject_me_if_new').present? && !persisted?
+ attributes.delete("_reject_me_if_new").present? && !persisted?
end
attr_accessor :cancel_save_from_callback, :parrots_limit
@@ -82,11 +82,11 @@ class Pirate < ActiveRecord::Base
end
class DestructivePirate < Pirate
- has_one :dependent_ship, :class_name => 'Ship', :foreign_key => :pirate_id, :dependent => :destroy
+ has_one :dependent_ship, :class_name => "Ship", :foreign_key => :pirate_id, :dependent => :destroy
end
class FamousPirate < ActiveRecord::Base
- self.table_name = 'pirates'
+ self.table_name = "pirates"
has_many :famous_ships
validates_presence_of :catchphrase, on: :conference
end
diff --git a/activerecord/test/models/possession.rb b/activerecord/test/models/possession.rb
index ddf759113b..0226336c16 100644
--- a/activerecord/test/models/possession.rb
+++ b/activerecord/test/models/possession.rb
@@ -1,3 +1,3 @@
class Possession < ActiveRecord::Base
- self.table_name = 'having'
+ self.table_name = "having"
end
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index bf3079a1df..395ba37e0b 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -7,7 +7,7 @@ class Post < ActiveRecord::Base
module NamedExtension
def author
- 'lifo'
+ "lifo"
end
end
@@ -31,11 +31,11 @@ class Post < ActiveRecord::Base
def first_comment
super.body
end
- has_one :first_comment, -> { order('id ASC') }, :class_name => 'Comment'
- has_one :last_comment, -> { order('id desc') }, :class_name => 'Comment'
+ 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) }
@@ -77,60 +77,60 @@ class Post < ActiveRecord::Base
has_one :very_special_comment
has_one :very_special_comment_with_post, -> { includes(:post) }, :class_name => "VerySpecialComment"
- has_one :very_special_comment_with_post_with_joins, -> { joins(:post).order('posts.id') }, class_name: "VerySpecialComment"
+ has_one :very_special_comment_with_post_with_joins, -> { joins(:post).order("posts.id") }, class_name: "VerySpecialComment"
has_many :special_comments
- has_many :nonexistent_comments, -> { where 'comments.id < 0' }, :class_name => 'Comment'
+ has_many :nonexistent_comments, -> { where "comments.id < 0" }, :class_name => "Comment"
has_many :special_comments_ratings, :through => :special_comments, :source => :ratings
has_many :special_comments_ratings_taggings, :through => :special_comments_ratings, :source => :taggings
- has_many :category_posts, :class_name => 'CategoryPost'
+ has_many :category_posts, :class_name => "CategoryPost"
has_many :scategories, through: :category_posts, source: :category
has_and_belongs_to_many :categories
- has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => 'category_id'
+ has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => "category_id"
has_many :taggings, :as => :taggable, :counter_cache => :tags_count
has_many :tags, :through => :taggings do
def add_joins_and_select
- select('tags.*, authors.id as author_id')
- .joins('left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id')
+ select("tags.*, authors.id as author_id")
+ .joins("left outer join posts on taggings.taggable_id = posts.id left outer join authors on posts.author_id = authors.id")
.to_a
end
end
- has_many :taggings_with_delete_all, :class_name => 'Tagging', :as => :taggable, :dependent => :delete_all, counter_cache: :taggings_with_delete_all_count
- has_many :taggings_with_destroy, :class_name => 'Tagging', :as => :taggable, :dependent => :destroy, counter_cache: :taggings_with_destroy_count
+ has_many :taggings_with_delete_all, :class_name => "Tagging", :as => :taggable, :dependent => :delete_all, counter_cache: :taggings_with_delete_all_count
+ has_many :taggings_with_destroy, :class_name => "Tagging", :as => :taggable, :dependent => :destroy, counter_cache: :taggings_with_destroy_count
has_many :tags_with_destroy, :through => :taggings, :source => :tag, :dependent => :destroy, counter_cache: :tags_with_destroy_count
has_many :tags_with_nullify, :through => :taggings, :source => :tag, :dependent => :nullify, counter_cache: :tags_with_nullify_count
- has_many :misc_tags, -> { where :tags => { :name => 'Misc' } }, :through => :taggings, :source => :tag
+ has_many :misc_tags, -> { where :tags => { :name => "Misc" } }, :through => :taggings, :source => :tag
has_many :funky_tags, :through => :taggings, :source => :tag
has_many :super_tags, :through => :taggings
has_many :tags_with_primary_key, :through => :taggings, :source => :tag_with_primary_key
has_one :tagging, :as => :taggable
- has_many :first_taggings, -> { where :taggings => { :comment => 'first' } }, :as => :taggable, :class_name => 'Tagging'
- has_many :first_blue_tags, -> { where :tags => { :name => 'Blue' } }, :through => :first_taggings, :source => :tag
+ has_many :first_taggings, -> { where :taggings => { :comment => "first" } }, :as => :taggable, :class_name => "Tagging"
+ has_many :first_blue_tags, -> { where :tags => { :name => "Blue" } }, :through => :first_taggings, :source => :tag
- has_many :first_blue_tags_2, -> { where :taggings => { :comment => 'first' } }, :through => :taggings, :source => :blue_tag
+ has_many :first_blue_tags_2, -> { where :taggings => { :comment => "first" } }, :through => :taggings, :source => :blue_tag
- has_many :invalid_taggings, -> { where 'taggings.id < 0' }, :as => :taggable, :class_name => "Tagging"
+ has_many :invalid_taggings, -> { where "taggings.id < 0" }, :as => :taggable, :class_name => "Tagging"
has_many :invalid_tags, :through => :invalid_taggings, :source => :tag
has_many :categorizations, :foreign_key => :category_id
has_many :authors, :through => :categorizations
- has_many :categorizations_using_author_id, :primary_key => :author_id, :foreign_key => :post_id, :class_name => 'Categorization'
+ has_many :categorizations_using_author_id, :primary_key => :author_id, :foreign_key => :post_id, :class_name => "Categorization"
has_many :authors_using_author_id, :through => :categorizations_using_author_id, :source => :author
- has_many :taggings_using_author_id, :primary_key => :author_id, :as => :taggable, :class_name => 'Tagging'
+ has_many :taggings_using_author_id, :primary_key => :author_id, :as => :taggable, :class_name => "Tagging"
has_many :tags_using_author_id, :through => :taggings_using_author_id, :source => :tag
has_many :images, :as => :imageable, :foreign_key => :imageable_identifier, :foreign_type => :imageable_class
- has_one :main_image, :as => :imageable, :foreign_key => :imageable_identifier, :foreign_type => :imageable_class, :class_name => 'Image'
+ has_one :main_image, :as => :imageable, :foreign_key => :imageable_identifier, :foreign_type => :imageable_class, :class_name => "Image"
- has_many :standard_categorizations, :class_name => 'Categorization', :foreign_key => :post_id
+ has_many :standard_categorizations, :class_name => "Categorization", :foreign_key => :post_id
has_many :author_using_custom_pk, :through => :standard_categorizations
has_many :authors_using_custom_pk, :through => :standard_categorizations
has_many :named_categories, :through => :standard_categorizations
@@ -145,14 +145,14 @@ class Post < ActiveRecord::Base
: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 :skimmers, -> { where :skimmer => true }, :class_name => "Reader"
has_many :impatient_people, :through => :skimmers, :source => :person
has_many :lazy_readers
- has_many :lazy_readers_skimmers_or_not, -> { where(skimmer: [ true, false ]) }, :class_name => 'LazyReader'
+ has_many :lazy_readers_skimmers_or_not, -> { where(skimmer: [ true, false ]) }, :class_name => "LazyReader"
has_many :lazy_people, :through => :lazy_readers, :source => :person
- has_many :lazy_readers_unscope_skimmers, -> { skimmers_or_not }, :class_name => 'LazyReader'
+ has_many :lazy_readers_unscope_skimmers, -> { skimmers_or_not }, :class_name => "LazyReader"
has_many :lazy_people_unscope_skimmers, :through => :lazy_readers_unscope_skimmers, :source => :person
def self.top(limit)
@@ -186,7 +186,7 @@ end
class FirstPost < ActiveRecord::Base
self.inheritance_column = :disabled
- self.table_name = 'posts'
+ self.table_name = "posts"
default_scope { where(:id => 1) }
has_many :comments, :foreign_key => :post_id
@@ -195,47 +195,47 @@ end
class PostWithDefaultInclude < ActiveRecord::Base
self.inheritance_column = :disabled
- self.table_name = 'posts'
+ self.table_name = "posts"
default_scope { includes(:comments) }
has_many :comments, :foreign_key => :post_id
end
class PostWithSpecialCategorization < Post
has_many :categorizations, :foreign_key => :post_id
- default_scope { where(:type => 'PostWithSpecialCategorization').joins(:categorizations).where(:categorizations => { :special => true }) }
+ default_scope { where(:type => "PostWithSpecialCategorization").joins(:categorizations).where(:categorizations => { :special => true }) }
end
class PostWithDefaultScope < ActiveRecord::Base
self.inheritance_column = :disabled
- self.table_name = 'posts'
+ self.table_name = "posts"
default_scope { order(:title) }
end
class PostWithPreloadDefaultScope < ActiveRecord::Base
- self.table_name = 'posts'
+ self.table_name = "posts"
- has_many :readers, foreign_key: 'post_id'
+ has_many :readers, foreign_key: "post_id"
default_scope { preload(:readers) }
end
class PostWithIncludesDefaultScope < ActiveRecord::Base
- self.table_name = 'posts'
+ self.table_name = "posts"
- has_many :readers, foreign_key: 'post_id'
+ has_many :readers, foreign_key: "post_id"
default_scope { includes(:readers) }
end
class SpecialPostWithDefaultScope < ActiveRecord::Base
self.inheritance_column = :disabled
- self.table_name = 'posts'
+ self.table_name = "posts"
default_scope { where(:id => [1, 5,6]) }
end
class PostThatLoadsCommentsInAnAfterSaveHook < ActiveRecord::Base
self.inheritance_column = :disabled
- self.table_name = 'posts'
+ self.table_name = "posts"
has_many :comments, class_name: "CommentThatAutomaticallyAltersPostBody", foreign_key: :post_id
after_save do |post|
@@ -245,7 +245,7 @@ end
class PostWithAfterCreateCallback < ActiveRecord::Base
self.inheritance_column = :disabled
- self.table_name = 'posts'
+ self.table_name = "posts"
has_many :comments, foreign_key: :post_id
after_create do |post|
@@ -255,7 +255,7 @@ end
class PostWithCommentWithDefaultScopeReferencesAssociation < ActiveRecord::Base
self.inheritance_column = :disabled
- self.table_name = 'posts'
+ self.table_name = "posts"
has_many :comment_with_default_scope_references_associations, foreign_key: :post_id
has_one :first_comment, class_name: "CommentWithDefaultScopeReferencesAssociation", foreign_key: :post_id
end
@@ -265,7 +265,7 @@ class SerializedPost < ActiveRecord::Base
end
class ConditionalStiPost < Post
- default_scope { where(title: 'Untitled') }
+ default_scope { where(title: "Untitled") }
end
class SubConditionalStiPost < ConditionalStiPost
diff --git a/activerecord/test/models/professor.rb b/activerecord/test/models/professor.rb
index 7654eda0ef..4dfb1a9602 100644
--- a/activerecord/test/models/professor.rb
+++ b/activerecord/test/models/professor.rb
@@ -1,4 +1,4 @@
-require_dependency 'models/arunit2_model'
+require_dependency "models/arunit2_model"
class Professor < ARUnit2Model
has_and_belongs_to_many :courses
diff --git a/activerecord/test/models/project.rb b/activerecord/test/models/project.rb
index efa8246f1e..1b3b807ee2 100644
--- a/activerecord/test/models/project.rb
+++ b/activerecord/test/models/project.rb
@@ -1,11 +1,11 @@
class Project < ActiveRecord::Base
belongs_to :mentor
- has_and_belongs_to_many :developers, -> { distinct.order 'developers.name desc, developers.id desc' }
+ has_and_belongs_to_many :developers, -> { distinct.order "developers.name desc, developers.id desc" }
has_and_belongs_to_many :readonly_developers, -> { readonly }, :class_name => "Developer"
- has_and_belongs_to_many :non_unique_developers, -> { order 'developers.name desc, developers.id desc' }, :class_name => 'Developer'
+ has_and_belongs_to_many :non_unique_developers, -> { order "developers.name desc, developers.id desc" }, :class_name => "Developer"
has_and_belongs_to_many :limited_developers, -> { limit 1 }, :class_name => "Developer"
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 :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>'}"},
diff --git a/activerecord/test/models/reader.rb b/activerecord/test/models/reader.rb
index 91afc1898c..8c7235ba9a 100644
--- a/activerecord/test/models/reader.rb
+++ b/activerecord/test/models/reader.rb
@@ -1,7 +1,7 @@
class Reader < ActiveRecord::Base
belongs_to :post
belongs_to :person, :inverse_of => :readers
- belongs_to :single_person, :class_name => 'Person', :foreign_key => :person_id, :inverse_of => :reader
+ belongs_to :single_person, :class_name => "Person", :foreign_key => :person_id, :inverse_of => :reader
belongs_to :first_post, -> { where(id: [2, 3]) }
end
diff --git a/activerecord/test/models/reference.rb b/activerecord/test/models/reference.rb
index c2f9068f57..1cf6669dce 100644
--- a/activerecord/test/models/reference.rb
+++ b/activerecord/test/models/reference.rb
@@ -17,6 +17,6 @@ class Reference < ActiveRecord::Base
end
class BadReference < ActiveRecord::Base
- self.table_name = 'references'
+ self.table_name = "references"
default_scope { where(:favourite => false) }
end
diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb
index 3e82e55d89..34b60bdef1 100644
--- a/activerecord/test/models/reply.rb
+++ b/activerecord/test/models/reply.rb
@@ -1,4 +1,4 @@
-require 'models/topic'
+require "models/topic"
class Reply < Topic
belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
@@ -7,8 +7,8 @@ class Reply < Topic
end
class UniqueReply < Reply
- belongs_to :topic, :foreign_key => 'parent_id', :counter_cache => true
- validates_uniqueness_of :content, :scope => 'parent_id'
+ belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
+ validates_uniqueness_of :content, :scope => "parent_id"
end
class SillyUniqueReply < UniqueReply
@@ -56,6 +56,6 @@ end
module Web
class Reply < Web::Topic
- belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true, :class_name => 'Web::Topic'
+ belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true, :class_name => "Web::Topic"
end
end
diff --git a/activerecord/test/models/ship.rb b/activerecord/test/models/ship.rb
index e333b964ab..eae360a9eb 100644
--- a/activerecord/test/models/ship.rb
+++ b/activerecord/test/models/ship.rb
@@ -2,9 +2,9 @@ class Ship < ActiveRecord::Base
self.record_timestamps = false
belongs_to :pirate
- belongs_to :update_only_pirate, :class_name => 'Pirate'
+ belongs_to :update_only_pirate, :class_name => "Pirate"
belongs_to :developer, dependent: :destroy
- has_many :parts, :class_name => 'ShipPart'
+ has_many :parts, :class_name => "ShipPart"
has_many :treasures
accepts_nested_attributes_for :parts, :allow_destroy => true
@@ -33,7 +33,7 @@ class Prisoner < ActiveRecord::Base
end
class FamousShip < ActiveRecord::Base
- self.table_name = 'ships'
+ self.table_name = "ships"
belongs_to :famous_pirate
validates_presence_of :name, on: :conference
end
diff --git a/activerecord/test/models/sponsor.rb b/activerecord/test/models/sponsor.rb
index ec3dcf8a97..5f7e47b583 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,
- :foreign_type => 'sponsorable_type', :foreign_key => 'sponsorable_id'
+ belongs_to :sponsorable_with_conditions, -> { where :name => "Ernie"}, :polymorphic => true,
+ :foreign_type => "sponsorable_type", :foreign_key => "sponsorable_id"
end
diff --git a/activerecord/test/models/subject.rb b/activerecord/test/models/subject.rb
index 8e28f8b86b..9b96f11c9d 100644
--- a/activerecord/test/models/subject.rb
+++ b/activerecord/test/models/subject.rb
@@ -9,7 +9,7 @@ class Subject < ActiveRecord::Base
protected
def set_email_address
unless self.persisted?
- self.author_email_address = 'test@test.com'
+ self.author_email_address = "test@test.com"
end
end
diff --git a/activerecord/test/models/subscriber.rb b/activerecord/test/models/subscriber.rb
index 76e85a0cd3..269da472cf 100644
--- a/activerecord/test/models/subscriber.rb
+++ b/activerecord/test/models/subscriber.rb
@@ -1,5 +1,5 @@
class Subscriber < ActiveRecord::Base
- self.primary_key = 'nick'
+ self.primary_key = "nick"
has_many :subscriptions
has_many :books, :through => :subscriptions
end
diff --git a/activerecord/test/models/tag.rb b/activerecord/test/models/tag.rb
index b48b9a2155..a49affaf3f 100644
--- a/activerecord/test/models/tag.rb
+++ b/activerecord/test/models/tag.rb
@@ -3,11 +3,11 @@ class Tag < ActiveRecord::Base
has_many :taggables, :through => :taggings
has_one :tagging
- has_many :tagged_posts, :through => :taggings, :source => 'taggable', :source_type => 'Post'
+ has_many :tagged_posts, :through => :taggings, :source => "taggable", :source_type => "Post"
end
class OrderedTag < Tag
self.table_name = "tags"
- has_many :taggings, -> { order('taggings.id DESC') }, foreign_key: 'tag_id'
+ has_many :taggings, -> { order("taggings.id DESC") }, foreign_key: "tag_id"
end
diff --git a/activerecord/test/models/tagging.rb b/activerecord/test/models/tagging.rb
index a6c05da26a..3ab9f50739 100644
--- a/activerecord/test/models/tagging.rb
+++ b/activerecord/test/models/tagging.rb
@@ -4,10 +4,10 @@ end
class Tagging < ActiveRecord::Base
belongs_to :tag, -> { includes(:tagging) }
- belongs_to :super_tag, :class_name => 'Tag', :foreign_key => 'super_tag_id'
- belongs_to :invalid_tag, :class_name => 'Tag', :foreign_key => 'tag_id'
- belongs_to :blue_tag, -> { where :tags => { :name => 'Blue' } }, :class_name => 'Tag', :foreign_key => :tag_id
- belongs_to :tag_with_primary_key, :class_name => 'Tag', :foreign_key => :tag_id, :primary_key => :custom_primary_key
+ belongs_to :super_tag, :class_name => "Tag", :foreign_key => "super_tag_id"
+ belongs_to :invalid_tag, :class_name => "Tag", :foreign_key => "tag_id"
+ belongs_to :blue_tag, -> { where :tags => { :name => "Blue" } }, :class_name => "Tag", :foreign_key => :tag_id
+ belongs_to :tag_with_primary_key, :class_name => "Tag", :foreign_key => :tag_id, :primary_key => :custom_primary_key
belongs_to :taggable, :polymorphic => true, :counter_cache => :tags_count
has_many :things, :through => :taggable
end
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index 21c23ed2a2..4e35e458ca 100644
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -2,7 +2,7 @@ class Topic < ActiveRecord::Base
scope :base, -> { all }
scope :written_before, lambda { |time|
if time
- where 'written_on < ?', time
+ where "written_on < ?", time
end
}
scope :approved, -> { where(:approved => true) }
@@ -10,10 +10,10 @@ class Topic < ActiveRecord::Base
scope :scope_with_lambda, lambda { all }
- scope :by_lifo, -> { where(:author_name => 'lifo') }
- scope :replied, -> { where 'replies_count > 0' }
+ scope :by_lifo, -> { where(:author_name => "lifo") }
+ scope :replied, -> { where "replies_count > 0" }
- scope 'approved_as_string', -> { where(:approved => true) }
+ scope "approved_as_string", -> { where(:approved => true) }
scope :anonymous_extension, -> { all } do
def one
1
@@ -33,7 +33,7 @@ class Topic < ActiveRecord::Base
end
has_many :replies, dependent: :destroy, foreign_key: "parent_id", autosave: true
- has_many :approved_replies, -> { approved }, class_name: 'Reply', foreign_key: "parent_id", counter_cache: 'replies_count'
+ has_many :approved_replies, -> { approved }, class_name: "Reply", foreign_key: "parent_id", counter_cache: "replies_count"
has_many :unique_replies, :dependent => :destroy, :foreign_key => "parent_id"
has_many :silly_unique_replies, :dependent => :destroy, :foreign_key => "parent_id"
@@ -85,7 +85,7 @@ class Topic < ActiveRecord::Base
def set_email_address
unless self.persisted?
- self.author_email_address = 'test@test.com'
+ self.author_email_address = "test@test.com"
end
end
@@ -113,6 +113,6 @@ end
module Web
class Topic < ActiveRecord::Base
- has_many :replies, :dependent => :destroy, :foreign_key => "parent_id", :class_name => 'Web::Reply'
+ has_many :replies, :dependent => :destroy, :foreign_key => "parent_id", :class_name => "Web::Reply"
end
end
diff --git a/activerecord/test/models/treasure.rb b/activerecord/test/models/treasure.rb
index 63ff0c23ec..04c3ef662c 100644
--- a/activerecord/test/models/treasure.rb
+++ b/activerecord/test/models/treasure.rb
@@ -5,7 +5,7 @@ class Treasure < ActiveRecord::Base
belongs_to :ship
has_many :price_estimates, :as => :estimate_of
- has_and_belongs_to_many :rich_people, join_table: 'peoples_treasures', validate: false
+ has_and_belongs_to_many :rich_people, join_table: "peoples_treasures", validate: false
accepts_nested_attributes_for :looter
end
diff --git a/activerecord/test/models/user.rb b/activerecord/test/models/user.rb
index 97107a35a0..47649e0a77 100644
--- a/activerecord/test/models/user.rb
+++ b/activerecord/test/models/user.rb
@@ -1,4 +1,4 @@
-require 'models/job'
+require "models/job"
class User < ActiveRecord::Base
has_secure_token
@@ -6,7 +6,7 @@ class User < ActiveRecord::Base
has_and_belongs_to_many :jobs_pool,
class_name: Job,
- join_table: 'jobs_pool'
+ join_table: "jobs_pool"
end
class UserWithNotification < User
diff --git a/activerecord/test/models/vegetables.rb b/activerecord/test/models/vegetables.rb
index 1f41cde3a5..5f6a17dbb3 100644
--- a/activerecord/test/models/vegetables.rb
+++ b/activerecord/test/models/vegetables.rb
@@ -3,7 +3,7 @@ class Vegetable < ActiveRecord::Base
validates_presence_of :name
def self.inheritance_column
- 'custom_type'
+ "custom_type"
end
end
@@ -20,5 +20,5 @@ class KingCole < GreenCabbage
end
class RedCabbage < Cabbage
- belongs_to :seller, :class_name => 'Company'
+ belongs_to :seller, :class_name => "Company"
end
diff --git a/activerecord/test/models/vertex.rb b/activerecord/test/models/vertex.rb
index 48bb851e62..cd0ac92236 100644
--- a/activerecord/test/models/vertex.rb
+++ b/activerecord/test/models/vertex.rb
@@ -1,9 +1,9 @@
# This class models a vertex in a directed graph.
class Vertex < ActiveRecord::Base
- has_many :sink_edges, :class_name => 'Edge', :foreign_key => 'source_id'
+ has_many :sink_edges, :class_name => "Edge", :foreign_key => "source_id"
has_many :sinks, :through => :sink_edges
has_and_belongs_to_many :sources,
- :class_name => 'Vertex', :join_table => 'edges',
- :foreign_key => 'sink_id', :association_foreign_key => 'source_id'
+ :class_name => "Vertex", :join_table => "edges",
+ :foreign_key => "sink_id", :association_foreign_key => "source_id"
end