diff options
author | Ben Toews <mastahyeti@gmail.com> | 2017-10-11 13:16:57 -0600 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2017-11-09 22:42:15 +1030 |
commit | 798557145c727b2abef2487783f02e57f04197c9 (patch) | |
tree | 82f1ff95da36955b72911b60197421e3d32d1e24 /activerecord/test/models | |
parent | 5180fe2cd8233169935065efe8762bd5d7b2709c (diff) | |
download | rails-798557145c727b2abef2487783f02e57f04197c9.tar.gz rails-798557145c727b2abef2487783f02e57f04197c9.tar.bz2 rails-798557145c727b2abef2487783f02e57f04197c9.zip |
try using regexes
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/author.rb | 20 | ||||
-rw-r--r-- | activerecord/test/models/category.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/comment.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/owner.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/person.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 6 | ||||
-rw-r--r-- | activerecord/test/models/project.rb | 4 |
7 files changed, 17 insertions, 21 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index f462fdb69a..cb8686f315 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -7,7 +7,7 @@ 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(Arel.sql("comments.id")) }, 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" @@ -20,15 +20,15 @@ class Author < ActiveRecord::Base end end has_many :comments_containing_the_letter_e, through: :posts, source: :comments - has_many :comments_with_order_and_conditions, -> { order(Arel.sql("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).where(posts: { type: "Post" }) }, through: :posts, source: :comments has_many :comments_for_first_author, -> { for_first_author }, through: :posts, source: :comments has_many :first_posts - has_many :comments_on_first_posts, -> { order(Arel.sql("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(Arel.sql("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" @@ -40,11 +40,11 @@ class Author < ActiveRecord::Base -> { where(title: "Welcome to the weblog").where(Post.arel_table[:comments_count].gt(0)) }, class_name: "Post" - has_many :comments_desc, -> { order(Arel.sql("comments.id DESC")) }, through: :posts, source: :comments + has_many :comments_desc, -> { order("comments.id DESC") }, through: :posts, source: :comments has_many :unordered_comments, -> { unscope(:order).distinct }, through: :posts_sorted_by_id_limited, source: :comments has_many :funky_comments, through: :posts, source: :comments - has_many :ordered_uniq_comments, -> { distinct.order(Arel.sql("comments.id")) }, through: :posts, source: :comments - has_many :ordered_uniq_comments_desc, -> { distinct.order(Arel.sql("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 @@ -107,15 +107,15 @@ class Author < ActiveRecord::Base has_many :similar_posts, -> { distinct }, through: :tags, source: :tagged_posts has_many :ordered_posts, -> { distinct }, through: :ordered_tags, source: :tagged_posts - has_many :distinct_tags, -> { select("DISTINCT tags.*").order(Arel.sql("tags.name")) }, through: :posts, source: :tags + has_many :distinct_tags, -> { select("DISTINCT tags.*").order("tags.name") }, through: :posts, source: :tags has_many :tags_with_primary_key, through: :posts has_many :books has_many :unpublished_books, -> { where(status: [:proposed, :written]) }, class_name: "Book" has_many :subscriptions, through: :books - has_many :subscribers, -> { order(Arel.sql("subscribers.nick")) }, through: :subscriptions - has_many :distinct_subscribers, -> { select("DISTINCT subscribers.*").order(Arel.sql("subscribers.nick")) }, through: :subscriptions, source: :subscriber + has_many :subscribers, -> { order("subscribers.nick") }, through: :subscriptions + has_many :distinct_subscribers, -> { select("DISTINCT subscribers.*").order("subscribers.nick") }, through: :subscriptions, source: :subscriber has_one :essay, primary_key: :name, as: :writer has_one :essay_category, through: :essay, source: :category diff --git a/activerecord/test/models/category.rb b/activerecord/test/models/category.rb index 3038264694..2ccc00bed9 100644 --- a/activerecord/test/models/category.rb +++ b/activerecord/test/models/category.rb @@ -4,7 +4,7 @@ class Category < ActiveRecord::Base has_and_belongs_to_many :posts has_and_belongs_to_many :special_posts, class_name: "Post" has_and_belongs_to_many :other_posts, class_name: "Post" - has_and_belongs_to_many :posts_with_authors_sorted_by_author_id, -> { includes(:authors).order(Arel.sql("authors.id")) }, class_name: "Post" + 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" }, diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index d5acfc0749..5ab433f2d9 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -81,7 +81,7 @@ class CommentThatAutomaticallyAltersPostBody < Comment end class CommentWithDefaultScopeReferencesAssociation < Comment - default_scope -> { includes(:developer).order(Arel.sql("developers.name")).references(:developer) } + default_scope -> { includes(:developer).order("developers.name").references(:developer) } belongs_to :developer end diff --git a/activerecord/test/models/owner.rb b/activerecord/test/models/owner.rb index ebaafdec5e..5fa50d9918 100644 --- a/activerecord/test/models/owner.rb +++ b/activerecord/test/models/owner.rb @@ -2,7 +2,7 @@ class Owner < ActiveRecord::Base self.primary_key = :owner_id - has_many :pets, -> { order Arel.sql("pets.name desc") } + has_many :pets, -> { order "pets.name desc" } has_many :toys, through: :pets has_many :persons, through: :pets diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb index 7067f1b6b0..5cba1e440e 100644 --- a/activerecord/test/models/person.rb +++ b/activerecord/test/models/person.rb @@ -19,7 +19,7 @@ class Person < ActiveRecord::Base 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(Arel.sql("comments.id")) }, through: :readers, source: :post + 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 diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 4508f727d0..780a2c17f5 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -85,7 +85,7 @@ 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(Arel.sql("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" @@ -323,9 +323,5 @@ class FakeKlass def enforce_raw_sql_whitelist(*args) # noop end - - def attribute_names_and_aliases - [] - end end end diff --git a/activerecord/test/models/project.rb b/activerecord/test/models/project.rb index 9b282a6729..846cef625b 100644 --- a/activerecord/test/models/project.rb +++ b/activerecord/test/models/project.rb @@ -2,9 +2,9 @@ class Project < ActiveRecord::Base belongs_to :mentor - has_and_belongs_to_many :developers, -> { distinct.order Arel.sql("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 Arel.sql("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" |