A platform for community discussion. Free, open, simple.
DEV: remove update_attributes which is deprecated in Rails 6
Sam Saffron45285f147704
diff --git a/app/controllers/admin/screened_ip_addresses_controller.rb b/app/controllers/admin/screened_ip_addresses_controller.rbindex 1447fe2dbc9..59f77425221 100644--- a/app/controllers/admin/screened_ip_addresses_controller.rb+++ b/app/controllers/admin/screened_ip_addresses_controller.rb@@ -32,7 +32,7 @@ class Admin::ScreenedIpAddressesController < Admin::AdminControllerenddef update- if @screened_ip_address.update_attributes(allowed_params)+ if @screened_ip_address.update(allowed_params)render_serialized(@screened_ip_address, ScreenedIpAddressSerializer)elserender_json_error(@screened_ip_address)diff --git a/app/controllers/admin/web_hooks_controller.rb b/app/controllers/admin/web_hooks_controller.rbindex 907bdfc69c2..d11c8bf396d 100644--- a/app/controllers/admin/web_hooks_controller.rb+++ b/app/controllers/admin/web_hooks_controller.rb@@ -42,7 +42,7 @@ class Admin::WebHooksController < Admin::AdminControllerenddef update- if @web_hook.update_attributes(web_hook_params)+ if @web_hook.update(web_hook_params)StaffActionLogger.new(current_user).log_web_hook(@web_hook, UserHistory.actions[:web_hook_update], changes: @web_hook.saved_changes)render_serialized(@web_hook, AdminWebHookSerializer, root: 'web_hook')else@@ -92,7 +92,7 @@ class Admin::WebHooksController < Admin::AdminControllernow = Time.zone.nowresponse = conn.post(headers: MultiJson.load(web_hook_event.headers), body: web_hook_event.payload)- web_hook_event.update_attributes!(status: response.status,+ web_hook_event.update!(status: response.status,response_headers: MultiJson.dump(response.headers),response_body: response.body,duration: ((Time.zone.now - now) * 1000).to_i)diff --git a/app/controllers/badges_controller.rb b/app/controllers/badges_controller.rbindex 902f3bfc3d5..f4f43ffcead 100644--- a/app/controllers/badges_controller.rb+++ b/app/controllers/badges_controller.rb@@ -45,7 +45,7 @@ class BadgesController < ApplicationControllerif current_useruser_badge = UserBadge.find_by(user_id: current_user.id, badge_id: @badge.id)if user_badge && user_badge.notification- user_badge.notification.update_attributes read: true+ user_badge.notification.update read: trueendif user_badge@badge.has_badge = truediff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rbindex ab9fdbe3a69..44435836da7 100644--- a/app/controllers/categories_controller.rb+++ b/app/controllers/categories_controller.rb@@ -175,7 +175,7 @@ class CategoriesController < ApplicationControllercustom_slug = params[:slug].to_s- if custom_slug.present? && @category.update_attributes(slug: custom_slug)+ if custom_slug.present? && @category.update(slug: custom_slug)render json: success_jsonelserender_json_error(@category)diff --git a/app/jobs/onceoff/fix_featured_link_for_topics.rb b/app/jobs/onceoff/fix_featured_link_for_topics.rbindex f05d552f8a7..205584d7a3b 100644--- a/app/jobs/onceoff/fix_featured_link_for_topics.rb+++ b/app/jobs/onceoff/fix_featured_link_for_topics.rb@@ -7,7 +7,7 @@ module JobsbeginURI.parse(featured_link)rescue URI::Error- topic.update_attributes(featured_link: URI.extract(featured_link).first)+ topic.update(featured_link: URI.extract(featured_link).first)endendenddiff --git a/app/models/category.rb b/app/models/category.rbindex 1ae55c4358f..fac08a8e8a5 100644--- a/app/models/category.rb+++ b/app/models/category.rb@@ -518,7 +518,7 @@ class Category < ActiveRecord::Base.pluck("topics.id").first- self.update_attributes(latest_topic_id: latest_topic_id, latest_post_id: latest_post_id)+ self.update(latest_topic_id: latest_topic_id, latest_post_id: latest_post_id)enddef self.query_parent_category(parent_slug)diff --git a/app/models/post.rb b/app/models/post.rbindex d39a4bc8c73..9f06916b109 100644--- a/app/models/post.rb+++ b/app/models/post.rb@@ -520,8 +520,8 @@ class Post < ActiveRecord::Baseenddef unhide!- self.update_attributes(hidden: false)- self.topic.update_attributes(visible: true) if is_first_post?+ self.update(hidden: false)+ self.topic.update(visible: true) if is_first_post?save(validate: false)publish_change_to_clients!(:acted)enddiff --git a/app/models/topic.rb b/app/models/topic.rbindex e685aa7ca82..bb5a0835ad1 100644--- a/app/models/topic.rb+++ b/app/models/topic.rb@@ -761,7 +761,7 @@ class Topic < ActiveRecord::Baseincrement!(:moderator_posts_count) if new_post.persisted?# If we are moving posts, we want to insert the moderator post where the previous posts were# in the stream, not at the end.- new_post.update_attributes!(post_number: opts[:post_number], sort_order: opts[:post_number]) if opts[:post_number].present?+ new_post.update!(post_number: opts[:post_number], sort_order: opts[:post_number]) if opts[:post_number].present?# Grab any links that are presentTopicLink.extract_from(new_post)diff --git a/app/services/badge_granter.rb b/app/services/badge_granter.rbindex 675a58e8321..44a1766e882 100644--- a/app/services/badge_granter.rb+++ b/app/services/badge_granter.rb@@ -53,7 +53,7 @@ class BadgeGranterbadge_title: @badge.allow_title,username: @user.username }.to_json)- user_badge.update_attributes notification_id: notification.id+ user_badge.update notification_id: notification.idendendenddiff --git a/app/services/color_scheme_revisor.rb b/app/services/color_scheme_revisor.rbindex 0057dedfa5e..36776ead7cc 100644--- a/app/services/color_scheme_revisor.rb+++ b/app/services/color_scheme_revisor.rb@@ -19,7 +19,7 @@ class ColorSchemeRevisorif has_colors@params[:colors].each do |c|if existing = @color_scheme.colors_by_name[c[:name]]- existing.update_attributes(c)+ existing.update(c)else@color_scheme.color_scheme_colors << ColorSchemeColor.new(name: c[:name], hex: c[:hex])enddiff --git a/app/services/topic_timestamp_changer.rb b/app/services/topic_timestamp_changer.rbindex a979d0a3475..8dffa3323da 100644--- a/app/services/topic_timestamp_changer.rb+++ b/app/services/topic_timestamp_changer.rb@@ -43,7 +43,7 @@ class TopicTimestampChangerenddef update_topic(last_posted_at)- @topic.update_attributes(+ @topic.update(created_at: @timestamp,updated_at: @timestamp,bumped_at: @timestamp,@@ -52,6 +52,6 @@ class TopicTimestampChangerenddef update_post(post, timestamp)- post.update_attributes(created_at: timestamp, updated_at: timestamp)+ post.update(created_at: timestamp, updated_at: timestamp)endenddiff --git a/app/services/user_merger.rb b/app/services/user_merger.rbindex 1f5709fd32d..7635c03b81d 100644--- a/app/services/user_merger.rb+++ b/app/services/user_merger.rb@@ -354,7 +354,7 @@ class UserMergerdef delete_source_user@source_user.reload- @source_user.update_attributes(+ @source_user.update(admin: false,email: "#{@source_user.username}_#{SecureRandom.hex}@no-email.invalid")diff --git a/lib/email/processor.rb b/lib/email/processor.rbindex a721244c519..469acfaca9c 100644--- a/lib/email/processor.rb+++ b/lib/email/processor.rb@@ -125,7 +125,7 @@ module Emailenddef set_incoming_email_rejection_message(incoming_email, message)- incoming_email.update_attributes!(rejection_message: message) if incoming_email+ incoming_email.update!(rejection_message: message) if incoming_emailenddef log_email_process_failure(mail_string, exception)diff --git a/lib/post_creator.rb b/lib/post_creator.rbindex b8514cce65a..0749312e8ad 100644--- a/lib/post_creator.rb+++ b/lib/post_creator.rb@@ -515,7 +515,7 @@ class PostCreator@user.user_stat.save!- @user.update_attributes(last_posted_at: @post.created_at)+ @user.update(last_posted_at: @post.created_at)enddef create_post_noticediff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rbindex cd53ab61f4e..e25b9e04620 100644--- a/lib/post_destroyer.rb+++ b/lib/post_destroyer.rb@@ -111,7 +111,7 @@ class PostDestroyercounts = Post.where(post_type: Post.types[:regular], topic_id: @post.topic_id).where('post_number > 1').group(:user_id).countcounts.each do |user_id, count|if user_stat = UserStat.where(user_id: user_id).first- user_stat.update_attributes(post_count: user_stat.post_count + count)+ user_stat.update(post_count: user_stat.post_count + count)endendend@@ -347,7 +347,7 @@ class PostDestroyercounts = Post.where(post_type: Post.types[:regular], topic_id: @post.topic_id).where('post_number > 1').group(:user_id).countcounts.each do |user_id, count|if user_stat = UserStat.where(user_id: user_id).first- user_stat.update_attributes(post_count: user_stat.post_count - count)+ user_stat.update(post_count: user_stat.post_count - count)endendenddiff --git a/spec/components/concern/category_hashtag_spec.rb b/spec/components/concern/category_hashtag_spec.rbindex d058ef1af9e..fd23b656988 100644--- a/spec/components/concern/category_hashtag_spec.rb+++ b/spec/components/concern/category_hashtag_spec.rb@@ -24,8 +24,8 @@ describe CategoryHashtag doendit "should be case sensitive" do- parent_category.update_attributes!(slug: "ApPlE")- child_category.update_attributes!(slug: "OraNGE")+ parent_category.update!(slug: "ApPlE")+ child_category.update!(slug: "OraNGE")expect(Category.query_from_hashtag_slug("apple")).to eq(nil)expect(Category.query_from_hashtag_slug("apple#{CategoryHashtag::SEPARATOR}orange")).to eq(nil)diff --git a/spec/components/cooked_post_processor_spec.rb b/spec/components/cooked_post_processor_spec.rbindex 19159fdc7a6..a6a28470225 100644--- a/spec/components/cooked_post_processor_spec.rb+++ b/spec/components/cooked_post_processor_spec.rb@@ -583,7 +583,7 @@ describe CookedPostProcessor doendit "should escape the filename" do- upload.update_attributes!(original_filename: "><img src=x onerror=alert('haha')>.png")+ upload.update!(original_filename: "><img src=x onerror=alert('haha')>.png")cpp.post_process_imagescpp.optimize_urlsdiff --git a/spec/components/file_store/s3_store_spec.rb b/spec/components/file_store/s3_store_spec.rbindex 5364eb4dff2..e942c2b41ac 100644--- a/spec/components/file_store/s3_store_spec.rb+++ b/spec/components/file_store/s3_store_spec.rb@@ -146,7 +146,7 @@ describe FileStore::S3Store doit "removes the file from s3 with the right paths" dostore.expects(:get_depth_for).with(upload.id).returns(0)s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once- upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/original/1X/#{upload.sha1}.png")+ upload.update!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/original/1X/#{upload.sha1}.png")s3_object = stubs3_bucket.expects(:object).with("tombstone/original/1X/#{upload.sha1}.png").returns(s3_object)@@ -164,7 +164,7 @@ describe FileStore::S3Store dostore.expects(:get_depth_for).with(upload.id).returns(0)s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once- optimized.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/#{path}")+ optimized.update!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/#{path}")s3_object = stubs3_bucket.expects(:object).with("tombstone/#{path}").returns(s3_object)@@ -183,7 +183,7 @@ describe FileStore::S3Store doit "removes the file from s3 with the right paths" dostore.expects(:get_depth_for).with(upload.id).returns(0)s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once- upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/discourse-uploads/original/1X/#{upload.sha1}.png")+ upload.update!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/discourse-uploads/original/1X/#{upload.sha1}.png")s3_object = stubs3_bucket.expects(:object).with("discourse-uploads/tombstone/original/1X/#{upload.sha1}.png").returns(s3_object)diff --git a/spec/components/plugin/instance_spec.rb b/spec/components/plugin/instance_spec.rbindex 52cb47e180c..5743936241e 100644--- a/spec/components/plugin/instance_spec.rb+++ b/spec/components/plugin/instance_spec.rb@@ -309,7 +309,7 @@ describe Plugin::Instance doexpect(called).to eq(1)- user.update_attributes!(username: 'some_username')+ user.update!(username: 'some_username')expect(called).to eq(1)end@@ -325,7 +325,7 @@ describe Plugin::Instance doexpect(called).to eq(1)- user.update_attributes!(username: 'some_username')+ user.update!(username: 'some_username')expect(called).to eq(1)enddiff --git a/spec/components/post_merger_spec.rb b/spec/components/post_merger_spec.rbindex 250712968af..50873dd37b8 100644--- a/spec/components/post_merger_spec.rb+++ b/spec/components/post_merger_spec.rb@@ -35,7 +35,7 @@ describe PostMerger doendit "should not allow the first post in a topic to be merged" do- post.update_attributes!(user: user)+ post.update!(user: user)reply1 = create_post(topic: topic, post_number: post.post_number, user: user)reply2 = create_post(topic: topic, post_number: post.post_number, user: user)diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rbindex f986e6d973d..02264c58182 100644--- a/spec/components/search_spec.rb+++ b/spec/components/search_spec.rb@@ -286,7 +286,7 @@ describe Search doendit "works for unlisted topics" do- topic.update_attributes(visible: false)+ topic.update(visible: false)_post = new_post('discourse is awesome', topic)results = Search.execute('discourse', search_context: topic)expect(results.posts.length).to eq(1)diff --git a/spec/components/stylesheet/manager_spec.rb b/spec/components/stylesheet/manager_spec.rbindex 00df90f8695..bf5d17134d5 100644--- a/spec/components/stylesheet/manager_spec.rb+++ b/spec/components/stylesheet/manager_spec.rb@@ -150,12 +150,12 @@ describe Stylesheet::Manager dodigest1 = manager.color_scheme_digest- category2.update_attributes(uploaded_background_id: 789, updated_at: 1.day.ago)+ category2.update(uploaded_background_id: 789, updated_at: 1.day.ago)digest2 = manager.color_scheme_digestexpect(digest2).to_not eq(digest1)- category1.update_attributes(uploaded_background_id: nil, updated_at: 5.minutes.ago)+ category1.update(uploaded_background_id: nil, updated_at: 5.minutes.ago)digest3 = manager.color_scheme_digestexpect(digest3).to_not eq(digest2)diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rbindex ad375ed36be..97c8afd63e5 100644--- a/spec/components/topic_query_spec.rb+++ b/spec/components/topic_query_spec.rb@@ -433,19 +433,19 @@ describe TopicQuery dodescribe "category default sort order" doit "can use category's default sort order" do- category.update_attributes!(sort_order: 'created', sort_ascending: true)+ category.update!(sort_order: 'created', sort_ascending: true)topic_ids = TopicQuery.new(user, category: category.id).list_latest.topics.map(&:id)expect(topic_ids - [topic_category.id]).to eq([topic_in_cat1.id, topic_in_cat2.id])endit "ignores invalid order value" do- category.update_attributes!(sort_order: 'funny')+ category.update!(sort_order: 'funny')topic_ids = TopicQuery.new(user, category: category.id).list_latest.topics.map(&:id)expect(topic_ids - [topic_category.id]).to eq([topic_in_cat2.id, topic_in_cat1.id])endit "can be overridden" do- category.update_attributes!(sort_order: 'created', sort_ascending: true)+ category.update!(sort_order: 'created', sort_ascending: true)topic_ids = TopicQuery.new(user, category: category.id, order: 'activity').list_latest.topics.map(&:id)expect(topic_ids - [topic_category.id]).to eq([topic_in_cat2.id, topic_in_cat1.id])enddiff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rbindex 11e1c2d29a0..b4e71e42503 100644--- a/spec/components/topic_view_spec.rb+++ b/spec/components/topic_view_spec.rb@@ -634,7 +634,7 @@ describe TopicView docontext "categorized topic" dolet(:category) { Fabricate(:category) }- before { topic.update_attributes(category_id: category.id) }+ before { topic.update(category_id: category.id) }context "topic_page_title_includes_category is false" dobefore { SiteSetting.topic_page_title_includes_category = false }diff --git a/spec/integration/category_tag_spec.rb b/spec/integration/category_tag_spec.rbindex d29b2f2147f..13dcbe56ee7 100644--- a/spec/integration/category_tag_spec.rb+++ b/spec/integration/category_tag_spec.rb@@ -73,7 +73,7 @@ describe "category tag restrictions" docontext 'category allows other tags to be used' dobefore do- category_with_tags.update_attributes!(allow_global_tags: true)+ category_with_tags.update!(allow_global_tags: true)endit "search can show the permitted tags" do@@ -88,7 +88,7 @@ describe "category tag restrictions" doendit "works if no tags are restricted to the category" do- other_category.update_attributes!(allow_global_tags: true)+ other_category.update!(allow_global_tags: true)expect(filter_allowed_tags(for_input: true, category: other_category)).to contain_exactly(tag3, tag4)expect(filter_allowed_tags(for_input: true, category: other_category, selected_tags: [tag3.name])).to contain_exactly(tag4)expect(filter_allowed_tags(for_input: true, category: other_category, selected_tags: [tag3.name], term: 'tag')).to contain_exactly(tag4)@@ -133,7 +133,7 @@ describe "category tag restrictions" docontext 'category allows other tags to be used' dobefore do- category.update_attributes!(allow_global_tags: true)+ category.update!(allow_global_tags: true)endit 'filters tags correctly' do@@ -148,7 +148,7 @@ describe "category tag restrictions" doendit "works if no tags are restricted to the category" do- other_category.update_attributes!(allow_global_tags: true)+ other_category.update!(allow_global_tags: true)expect(filter_allowed_tags(for_input: true, category: other_category)).to contain_exactly(tag3, tag4)tag_group1.tags = [tag2, tag3, tag4]expect(filter_allowed_tags(for_input: true, category: other_category)).to contain_exactly(tag1)@@ -258,9 +258,9 @@ describe "category tag restrictions" docontext "limit one tag from each group" dobefore do- makes.update_attributes(one_per_topic: true)- honda_group.update_attributes(one_per_topic: true)- ford_group.update_attributes(one_per_topic: true)+ makes.update(one_per_topic: true)+ honda_group.update(one_per_topic: true)+ ford_group.update(one_per_topic: true)endit "can restrict one tag from each group" dodiff --git a/spec/jobs/clean_up_uploads_spec.rb b/spec/jobs/clean_up_uploads_spec.rbindex 645b7a17fef..0fad4b4c26e 100644--- a/spec/jobs/clean_up_uploads_spec.rb+++ b/spec/jobs/clean_up_uploads_spec.rb@@ -154,7 +154,7 @@ describe Jobs::CleanUpUploads doit "does not delete profile background uploads" doprofile_background_upload = fabricate_upload- UserProfile.last.update_attributes!(profile_background: profile_background_upload.url)+ UserProfile.last.update!(profile_background: profile_background_upload.url)Jobs::CleanUpUploads.new.execute(nil)@@ -164,7 +164,7 @@ describe Jobs::CleanUpUploads doit "does not delete card background uploads" docard_background_upload = fabricate_upload- UserProfile.last.update_attributes!(card_background: card_background_upload.url)+ UserProfile.last.update!(card_background: card_background_upload.url)Jobs::CleanUpUploads.new.execute(nil)diff --git a/spec/jobs/enqueue_digest_emails_spec.rb b/spec/jobs/enqueue_digest_emails_spec.rbindex e408676bc66..7b257b46add 100644--- a/spec/jobs/enqueue_digest_emails_spec.rb+++ b/spec/jobs/enqueue_digest_emails_spec.rb@@ -30,11 +30,11 @@ describe Jobs::EnqueueDigestEmails doexpect(Jobs::EnqueueDigestEmails.new.target_user_ids.include?(unapproved_user.id)).to eq(true)# As an admin- unapproved_user.update_attributes(admin: true, moderator: false)+ unapproved_user.update(admin: true, moderator: false)expect(Jobs::EnqueueDigestEmails.new.target_user_ids.include?(unapproved_user.id)).to eq(true)# As an approved user- unapproved_user.update_attributes(admin: false, moderator: false, approved: true)+ unapproved_user.update(admin: false, moderator: false, approved: true)expect(Jobs::EnqueueDigestEmails.new.target_user_ids.include?(unapproved_user.id)).to eq(true)endenddiff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rbindex a3edcb97293..50b1fe93a11 100644--- a/spec/jobs/reindex_search_spec.rb+++ b/spec/jobs/reindex_search_spec.rb@@ -21,7 +21,7 @@ describe Jobs::ReindexSearch domodel = Fabricate(m.to_sym)# so that search data can be reindexedsearch_data = model.send("#{m}_search_data")- search_data.update_attributes!(version: 0)+ search_data.update!(version: 0)model.reloadsubject.execute({})diff --git a/spec/jobs/tl3_promotions_spec.rb b/spec/jobs/tl3_promotions_spec.rbindex 58e39dcfd50..2a13f32e660 100644--- a/spec/jobs/tl3_promotions_spec.rb+++ b/spec/jobs/tl3_promotions_spec.rb@@ -4,7 +4,7 @@ describe Jobs::Tl3Promotions dodef create_qualifying_stats(user)user.create_user_stat if user.user_stat.nil?- user.user_stat.update_attributes!(+ user.user_stat.update!(days_visited: 1000,topic_reply_count: 1000,topics_entered: 1000,diff --git a/spec/jobs/user_email_spec.rb b/spec/jobs/user_email_spec.rbindex 16d0e6583a8..9131960bb36 100644--- a/spec/jobs/user_email_spec.rb+++ b/spec/jobs/user_email_spec.rb@@ -34,14 +34,14 @@ describe Jobs::UserEmail doendit "doesn't call the mailer when the user is staged" do- staged.update_attributes!(last_seen_at: 8.days.ago, last_emailed_at: 8.days.ago)+ staged.update!(last_seen_at: 8.days.ago, last_emailed_at: 8.days.ago)Jobs::UserEmail.new.execute(type: :digest, user_id: staged.id)expect(ActionMailer::Base.deliveries).to eq([])endcontext 'not emailed recently' dobefore do- user.update_attributes!(last_emailed_at: 8.days.ago)+ user.update!(last_emailed_at: 8.days.ago)endit "calls the mailer when the user exists" do@@ -52,8 +52,8 @@ describe Jobs::UserEmail docontext 'recently emailed' dobefore do- user.update_attributes!(last_emailed_at: 2.hours.ago)- user.user_option.update_attributes!(digest_after_minutes: 1.day.to_i / 60)+ user.update!(last_emailed_at: 2.hours.ago)+ user.user_option.update!(digest_after_minutes: 1.day.to_i / 60)endit 'skips sending digest email' do@@ -129,7 +129,7 @@ describe Jobs::UserEmail doendit "does send an email to a user that's been recently seen but has email_level set to always" do- user.user_option.update_attributes(email_level: UserOption.email_level_types[:always])+ user.user_option.update(email_level: UserOption.email_level_types[:always])PostTiming.create!(topic_id: post.topic_id, post_number: post.post_number, user_id: user.id, msecs: 100)Jobs::UserEmail.new.execute(@@ -158,16 +158,16 @@ describe Jobs::UserEmail doendit "doesn't send a PM email to a user that's been recently seen and has email_messages_level set to never" do- user.user_option.update_attributes(email_messages_level: UserOption.email_level_types[:never])- user.user_option.update_attributes(email_level: UserOption.email_level_types[:always])+ user.user_option.update(email_messages_level: UserOption.email_level_types[:never])+ user.user_option.update(email_level: UserOption.email_level_types[:always])Jobs::UserEmail.new.execute(type: :user_private_message, user_id: user.id, post_id: post.id)expect(ActionMailer::Base.deliveries).to eq([])endit "doesn't send a regular post email to a user that's been recently seen and has email_level set to never" do- user.user_option.update_attributes(email_messages_level: UserOption.email_level_types[:always])- user.user_option.update_attributes(email_level: UserOption.email_level_types[:never])+ user.user_option.update(email_messages_level: UserOption.email_level_types[:always])+ user.user_option.update(email_level: UserOption.email_level_types[:never])Jobs::UserEmail.new.execute(type: :user_replied, user_id: user.id, post_id: post.id)expect(ActionMailer::Base.deliveries).to eq([])@@ -248,7 +248,7 @@ describe Jobs::UserEmail doendit "doesn't send the email if user of the post has been deleted" do- post.update_attributes!(user_id: nil)+ post.update!(user_id: nil)Jobs::UserEmail.new.execute(type: :user_replied, user_id: user.id, post_id: post.id)expect(ActionMailer::Base.deliveries).to eq([])diff --git a/spec/models/category_spec.rb b/spec/models/category_spec.rbindex af47372859a..c7695476215 100644--- a/spec/models/category_spec.rb+++ b/spec/models/category_spec.rb@@ -311,31 +311,31 @@ describe Category doendit "renames the definition when renamed" do- @category.update_attributes(name: 'Troutfishing')+ @category.update(name: 'Troutfishing')@topic.reloadexpect(@topic.title).to match(/Troutfishing/)expect(@topic.fancy_title).to match(/Troutfishing/)endit "doesn't raise an error if there is no definition topic to rename (uncategorized)" do- expect { @category.update_attributes(name: 'Troutfishing', topic_id: nil) }.to_not raise_error+ expect { @category.update(name: 'Troutfishing', topic_id: nil) }.to_not raise_errorendit "creates permalink when category slug is changed" do- @category.update_attributes(slug: 'new-category')+ @category.update(slug: 'new-category')expect(Permalink.count).to eq(1)endit "reuses existing permalink when category slug is changed" dopermalink = Permalink.create!(url: "c/#{@category.slug}", category_id: 42)- expect { @category.update_attributes(slug: 'new-slug') }.to_not change { Permalink.count }+ expect { @category.update(slug: 'new-slug') }.to_not change { Permalink.count }expect(permalink.reload.category_id).to eq(@category.id)endit "creates permalink when sub category slug is changed" dosub_category = Fabricate(:category, slug: 'sub-category', parent_category_id: @category.id)- sub_category.update_attributes(slug: 'new-sub-category')+ sub_category.update(slug: 'new-sub-category')expect(Permalink.count).to eq(1)end@@ -356,7 +356,7 @@ describe Category doGlobalSetting.stubs(:relative_url_root).returns('/forum')Discourse.stubs(:base_uri).returns("/forum")old_url = @category.url- @category.update_attributes(slug: 'new-category')+ @category.update(slug: 'new-category')permalink = Permalink.lastexpect(permalink.url).to eq(old_url[1..-1])enddiff --git a/spec/models/group_history_spec.rb b/spec/models/group_history_spec.rbindex baa0e43f306..55f6de4c449 100644--- a/spec/models/group_history_spec.rb+++ b/spec/models/group_history_spec.rb@@ -26,7 +26,7 @@ RSpec.describe GroupHistory doendit 'should filter by subject correctly' do- other_group_history.update_attributes!(subject: "test")+ other_group_history.update!(subject: "test")expect(described_class.with_filters(group_history.group,@@ -35,8 +35,8 @@ RSpec.describe GroupHistory doendit 'should filter by multiple filters correctly' do- group_history.update_attributes!(action: GroupHistory.actions[:remove_user_from_group])- other_group_history.update_attributes!(subject: "test")+ group_history.update!(action: GroupHistory.actions[:remove_user_from_group])+ other_group_history.update!(subject: "test")expect(described_class.with_filters(group_history.group,action: GroupHistory.actions[3], subject: 'test'diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rbindex 45988094cd6..425187e4af2 100644--- a/spec/models/group_spec.rb+++ b/spec/models/group_spec.rb@@ -617,7 +617,7 @@ describe Group doit 'should cook the bio' dogroup = Fabricate(:group)- group.update_attributes!(bio_raw: 'This is a group for :unicorn: lovers')+ group.update!(bio_raw: 'This is a group for :unicorn: lovers')expect(group.bio_cooked).to include("unicorn.png")enddiff --git a/spec/models/post_reply_spec.rb b/spec/models/post_reply_spec.rbindex d67ef33cae0..64a07ec3560 100644--- a/spec/models/post_reply_spec.rb+++ b/spec/models/post_reply_spec.rb@@ -13,7 +13,7 @@ describe PostReply doexpect(PostReply.new(post: post, reply: other_post)).to be_validother_topic = Fabricate(:topic)- other_post.update_attributes!(topic_id: other_topic.id)+ other_post.update!(topic_id: other_topic.id)other_post.reloadpost_reply = PostReply.new(post: post, reply: other_post)diff --git a/spec/models/user_search_spec.rb b/spec/models/user_search_spec.rbindex 2f4b9c484ad..4f6487d1f32 100644--- a/spec/models/user_search_spec.rb+++ b/spec/models/user_search_spec.rb@@ -28,7 +28,7 @@ describe UserSearch doFabricate :post, user: user6, topic: topicFabricate :post, user: staged, topic: topic4- user6.update_attributes(suspended_at: 1.day.ago, suspended_till: 1.year.from_now)+ user6.update(suspended_at: 1.day.ago, suspended_till: 1.year.from_now)enddef search_for(*args)diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex 94a1fb9536e..efc241a1806 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -1633,14 +1633,14 @@ describe User dodescribe 'when first notification has been seen' doit 'should return the right value' do- user.update_attributes!(seen_notification_id: notification.id)+ user.update!(seen_notification_id: notification.id)expect(user.reload.read_first_notification?).to eq(true)endenddescribe 'when user is trust level 1' doit 'should return the right value' do- user.update_attributes!(trust_level: TrustLevel[1])+ user.update!(trust_level: TrustLevel[1])expect(user.read_first_notification?).to eq(false)end@@ -1648,7 +1648,7 @@ describe User dodescribe 'when user is trust level 2' doit 'should return the right value' do- user.update_attributes!(trust_level: TrustLevel[2])+ user.update!(trust_level: TrustLevel[2])expect(user.read_first_notification?).to eq(true)end@@ -1656,7 +1656,7 @@ describe User dodescribe 'when user is an old user' doit 'should return the right value' do- user.update_attributes!(first_seen_at: 1.year.ago)+ user.update!(first_seen_at: 1.year.ago)expect(user.read_first_notification?).to eq(true)enddiff --git a/spec/multisite/s3_store_spec.rb b/spec/multisite/s3_store_spec.rbindex f5ac4e5bb16..f6175a4fcab 100644--- a/spec/multisite/s3_store_spec.rb+++ b/spec/multisite/s3_store_spec.rb@@ -63,7 +63,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite doupload = build_uploadstore.expects(:get_depth_for).with(upload.id).returns(0)s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once- upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/uploads/default/original/1X/#{upload.sha1}.png")+ upload.update!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/uploads/default/original/1X/#{upload.sha1}.png")s3_object = stubs3_bucket.expects(:object).with("uploads/tombstone/default/original/1X/#{upload.sha1}.png").returns(s3_object)@@ -80,7 +80,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite doupload = build_uploadstore.expects(:get_depth_for).with(upload.id).returns(0)s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once- upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/uploads/second/original/1X/#{upload.sha1}.png")+ upload.update!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/uploads/second/original/1X/#{upload.sha1}.png")s3_object = stubs3_bucket.expects(:object).with("uploads/tombstone/second/original/1X/#{upload.sha1}.png").returns(s3_object)@@ -102,7 +102,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite doupload = build_uploadstore.expects(:get_depth_for).with(upload.id).returns(0)s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once- upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/discourse-uploads/uploads/default/original/1X/#{upload.sha1}.png")+ upload.update!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/discourse-uploads/uploads/default/original/1X/#{upload.sha1}.png")s3_object = stubs3_bucket.expects(:object).with("discourse-uploads/uploads/tombstone/default/original/1X/#{upload.sha1}.png").returns(s3_object)diff --git a/spec/requests/admin/users_controller_spec.rb b/spec/requests/admin/users_controller_spec.rbindex 6c8aeae4a70..814da26c91f 100644--- a/spec/requests/admin/users_controller_spec.rb+++ b/spec/requests/admin/users_controller_spec.rb@@ -346,7 +346,7 @@ RSpec.describe Admin::UsersController dostat.posts_read_count = SiteSetting.tl1_requires_read_posts + 1stat.time_read = SiteSetting.tl1_requires_time_spent_mins * 60stat.save!- another_user.update_attributes(trust_level: TrustLevel[1])+ another_user.update(trust_level: TrustLevel[1])put "/admin/users/#{another_user.id}/trust_level.json", params: {level: TrustLevel[0]diff --git a/spec/requests/groups_controller_spec.rb b/spec/requests/groups_controller_spec.rbindex f4cac122fe1..06aed4203a5 100644--- a/spec/requests/groups_controller_spec.rb+++ b/spec/requests/groups_controller_spec.rb@@ -430,7 +430,7 @@ describe GroupsController doresponse_body = JSON.parse(response.body)expect(response_body["mentionable"]).to eq(false)- group.update_attributes!(+ group.update!(mentionable_level: Group::ALIAS_LEVELS[:everyone],visibility_level: Group.visibility_levels[:staff])@@ -561,7 +561,7 @@ describe GroupsController docontext "when user is group admin" dobefore do- user.update_attributes!(admin: true)+ user.update!(admin: true)sign_in(user)end@@ -804,7 +804,7 @@ describe GroupsController docontext 'public group' doit 'should be fobidden' do- group.update_attributes!(+ group.update!(public_admission: true,public_exit: true)@@ -1184,7 +1184,7 @@ describe GroupsController dodescribe 'when viewing a public group' dobefore do- group.update_attributes!(+ group.update!(public_admission: true,public_exit: true)diff --git a/spec/requests/invites_controller_spec.rb b/spec/requests/invites_controller_spec.rbindex 22e301edb5d..13f0f7c284b 100644--- a/spec/requests/invites_controller_spec.rb+++ b/spec/requests/invites_controller_spec.rb@@ -26,7 +26,7 @@ describe InvitesController doendit "returns error if invite has already been redeemed" do- invite.update_attributes!(redeemed_at: 1.day.ago)+ invite.update!(redeemed_at: 1.day.ago)get "/invites/#{invite.invite_key}"expect(response.status).to eq(200)diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rbindex afa4d58dc99..21acdd8300a 100644--- a/spec/requests/list_controller_spec.rb+++ b/spec/requests/list_controller_spec.rb@@ -416,7 +416,7 @@ RSpec.describe ListController dodescribe "category default views" doit "has a top default view" do- category.update_attributes!(default_view: 'top', default_top_period: 'monthly')+ category.update!(default_view: 'top', default_top_period: 'monthly')get "/c/#{category.slug}.json"expect(response.status).to eq(200)json = JSON.parse(response.body)@@ -424,7 +424,7 @@ RSpec.describe ListController doendit "has a default view of nil" do- category.update_attributes!(default_view: nil)+ category.update!(default_view: nil)get "/c/#{category.slug}.json"expect(response.status).to eq(200)json = JSON.parse(response.body)@@ -432,7 +432,7 @@ RSpec.describe ListController doendit "has a default view of ''" do- category.update_attributes!(default_view: '')+ category.update!(default_view: '')get "/c/#{category.slug}.json"expect(response.status).to eq(200)json = JSON.parse(response.body)@@ -440,7 +440,7 @@ RSpec.describe ListController doendit "has a default view of latest" do- category.update_attributes!(default_view: 'latest')+ category.update!(default_view: 'latest')get "/c/#{category.slug}.json"expect(response.status).to eq(200)json = JSON.parse(response.body)diff --git a/spec/requests/theme_javascripts_controller_spec.rb b/spec/requests/theme_javascripts_controller_spec.rbindex 57a415e7c72..349dad4afe2 100644--- a/spec/requests/theme_javascripts_controller_spec.rb+++ b/spec/requests/theme_javascripts_controller_spec.rb@@ -9,7 +9,7 @@ describe ThemeJavascriptsController dodescribe '#show' dodef update_digest_and_get(digest)# actually set digest to make sure 404 is raised by router- javascript_cache.update_attributes(digest: digest)+ javascript_cache.update(digest: digest)get "/theme-javascripts/#{digest}.js"enddiff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rbindex eece747de99..da5b497d3e6 100644--- a/spec/requests/users_controller_spec.rb+++ b/spec/requests/users_controller_spec.rb@@ -1668,7 +1668,7 @@ describe UsersController doput "/u/#{user.username}/preferences/badge_title.json", params: { user_badge_id: user_badge.id }expect(user.reload.title).not_to eq(badge.display_name)- badge.update_attributes allow_title: true+ badge.update allow_title: trueput "/u/#{user.username}/preferences/badge_title.json", params: { user_badge_id: user_badge.id }diff --git a/spec/services/badge_granter_spec.rb b/spec/services/badge_granter_spec.rbindex c75f55b4d1b..69486d9825b 100644--- a/spec/services/badge_granter_spec.rb+++ b/spec/services/badge_granter_spec.rb@@ -266,7 +266,7 @@ describe BadgeGranter doaction = PostActionCreator.like(liker, post).post_action# Nice post badge- post.update_attributes like_count: 10+ post.update like_count: 10BadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: action)BadgeGranter.process_queue!@@ -275,19 +275,19 @@ describe BadgeGranter doexpect(UserBadge.where(user_id: user.id, badge_id: Badge::NicePost).count).to eq(1)# Good post badge- post.update_attributes like_count: 25+ post.update like_count: 25BadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: action)BadgeGranter.process_queue!expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GoodPost)).not_to eq(nil)# Great post badge- post.update_attributes like_count: 50+ post.update like_count: 50BadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: action)BadgeGranter.process_queue!expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost)).not_to eq(nil)# Revoke badges on unlike- post.update_attributes like_count: 49+ post.update like_count: 49BadgeGranter.backfill(Badge.find(Badge::GreatPost))expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost)).to eq(nil)enddiff --git a/spec/services/group_action_logger_spec.rb b/spec/services/group_action_logger_spec.rbindex ec08846c770..6091596ff7e 100644--- a/spec/services/group_action_logger_spec.rb+++ b/spec/services/group_action_logger_spec.rb@@ -119,7 +119,7 @@ RSpec.describe GroupActionLogger dodescribe '#log_change_group_settings' doit 'should create the right record' do- group.update_attributes!(public_admission: true, created_at: Time.zone.now)+ group.update!(public_admission: true, created_at: Time.zone.now)expect { subject.log_change_group_settings }.to change { GroupHistory.count }.by(1)diff --git a/spec/services/search_indexer_spec.rb b/spec/services/search_indexer_spec.rbindex 5762ffd1467..faeda4bd5c0 100644--- a/spec/services/search_indexer_spec.rb+++ b/spec/services/search_indexer_spec.rb@@ -75,7 +75,7 @@ describe SearchIndexer doit 'correctly indexes a post according to version' do# Preparing so that they can be indexed to right versionSearchIndexer.update_posts_index(post_id, "dummy", "", nil, nil)- PostSearchData.find_by(post_id: post_id).update_attributes!(version: -1)+ PostSearchData.find_by(post_id: post_id).update!(version: -1)data = "<a>This</a> is a test"SearchIndexer.update_posts_index(post_id, "", "", nil, data)diff --git a/spec/services/user_anonymizer_spec.rb b/spec/services/user_anonymizer_spec.rbindex afeb76beaa2..da19ae94c98 100644--- a/spec/services/user_anonymizer_spec.rb+++ b/spec/services/user_anonymizer_spec.rb@@ -72,10 +72,10 @@ describe UserAnonymizer doendit "resets profile to default values" do- user.update_attributes(name: "Bibi", date_of_birth: 19.years.ago, title: "Super Star")+ user.update(name: "Bibi", date_of_birth: 19.years.ago, title: "Super Star")profile = user.reload.user_profile- profile.update_attributes(location: "Moose Jaw",+ profile.update(location: "Moose Jaw",website: "www.bim.com",bio_raw: "I'm Bibi from Moosejaw. I sing and dance.",bio_cooked: "I'm Bibi from Moosejaw. I sing and dance.",@@ -114,7 +114,7 @@ describe UserAnonymizer doit "changes name to anonymized username" doprev_username = user.username- user.update_attributes(name: "Bibi", date_of_birth: 19.years.ago, title: "Super Star")+ user.update(name: "Bibi", date_of_birth: 19.years.ago, title: "Super Star")make_anonymoususer.reloaddiff --git a/spec/services/user_updater_spec.rb b/spec/services/user_updater_spec.rbindex 31a8ca78961..f7db5982d75 100644--- a/spec/services/user_updater_spec.rb+++ b/spec/services/user_updater_spec.rb@@ -258,7 +258,7 @@ describe UserUpdater docontext 'badge can be used as a title' dobefore do- badge.update_attributes(allow_title: true)+ badge.update(allow_title: true)endit 'can use as title, sets badge_granted_title' do@@ -270,7 +270,7 @@ describe UserUpdater doendit 'badge has not been granted, does not change title' do- badge.update_attributes(allow_title: true)+ badge.update(allow_title: true)updater = UserUpdater.new(user, user)updater.update(title: badge.name)user.reload@@ -279,8 +279,8 @@ describe UserUpdater doendit 'changing to a title that is not from a badge, unsets badge_granted_title' do- user.update_attributes(title: badge.name)- user.user_profile.update_attributes(badge_granted_title: true)+ user.update(title: badge.name)+ user.user_profile.update(badge_granted_title: true)guardian = stubguardian.stubs(:can_grant_title?).with(user, 'Dancer').returns(true)diff --git a/spec/tasks/posts_spec.rb b/spec/tasks/posts_spec.rbindex 5631919fd21..a0cbe9338cd 100644--- a/spec/tasks/posts_spec.rb+++ b/spec/tasks/posts_spec.rb@@ -45,7 +45,7 @@ RSpec.describe "Post rake tasks" dodescribe 'rebake_match' doit 'rebakes matched posts' do- post.update_attributes(cooked: '')+ post.update(cooked: '')HighLine::Simulate.with('y') doRake::Task['posts:rebake_match'].invoke('brown')