diff --git a/app/controllers/admin/screened_ip_addresses_controller.rb b/app/controllers/admin/screened_ip_addresses_controller.rb
index 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::AdminController
end
def update
- if @screened_ip_address.update_attributes(allowed_params)
+ if @screened_ip_address.update(allowed_params)
render_serialized(@screened_ip_address, ScreenedIpAddressSerializer)
else
render_json_error(@screened_ip_address)
diff --git a/app/controllers/admin/web_hooks_controller.rb b/app/controllers/admin/web_hooks_controller.rb
index 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::AdminController
end
def 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::AdminController
now = Time.zone.now
response = 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.rb
index 902f3bfc3d5..f4f43ffcead 100644
--- a/app/controllers/badges_controller.rb
+++ b/app/controllers/badges_controller.rb
@@ -45,7 +45,7 @@ class BadgesController < ApplicationController
if current_user
user_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: true
end
if user_badge
@badge.has_badge = true
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index ab9fdbe3a69..44435836da7 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -175,7 +175,7 @@ class CategoriesController < ApplicationController
custom_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_json
else
render_json_error(@category)
diff --git a/app/jobs/onceoff/fix_featured_link_for_topics.rb b/app/jobs/onceoff/fix_featured_link_for_topics.rb
index 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 Jobs
begin
URI.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)
end
end
end
diff --git a/app/models/category.rb b/app/models/category.rb
index 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)
end
def self.query_parent_category(parent_slug)
diff --git a/app/models/post.rb b/app/models/post.rb
index d39a4bc8c73..9f06916b109 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -520,8 +520,8 @@ class Post < ActiveRecord::Base
end
def 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)
end
diff --git a/app/models/topic.rb b/app/models/topic.rb
index e685aa7ca82..bb5a0835ad1 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -761,7 +761,7 @@ class Topic < ActiveRecord::Base
increment!(: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 present
TopicLink.extract_from(new_post)
diff --git a/app/services/badge_granter.rb b/app/services/badge_granter.rb
index 675a58e8321..44a1766e882 100644
--- a/app/services/badge_granter.rb
+++ b/app/services/badge_granter.rb
@@ -53,7 +53,7 @@ class BadgeGranter
badge_title: @badge.allow_title,
username: @user.username }.to_json
)
- user_badge.update_attributes notification_id: notification.id
+ user_badge.update notification_id: notification.id
end
end
end
diff --git a/app/services/color_scheme_revisor.rb b/app/services/color_scheme_revisor.rb
index 0057dedfa5e..36776ead7cc 100644
--- a/app/services/color_scheme_revisor.rb
+++ b/app/services/color_scheme_revisor.rb
@@ -19,7 +19,7 @@ class ColorSchemeRevisor
if 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])
end
diff --git a/app/services/topic_timestamp_changer.rb b/app/services/topic_timestamp_changer.rb
index a979d0a3475..8dffa3323da 100644
--- a/app/services/topic_timestamp_changer.rb
+++ b/app/services/topic_timestamp_changer.rb
@@ -43,7 +43,7 @@ class TopicTimestampChanger
end
def update_topic(last_posted_at)
- @topic.update_attributes(
+ @topic.update(
created_at: @timestamp,
updated_at: @timestamp,
bumped_at: @timestamp,
@@ -52,6 +52,6 @@ class TopicTimestampChanger
end
def update_post(post, timestamp)
- post.update_attributes(created_at: timestamp, updated_at: timestamp)
+ post.update(created_at: timestamp, updated_at: timestamp)
end
end
diff --git a/app/services/user_merger.rb b/app/services/user_merger.rb
index 1f5709fd32d..7635c03b81d 100644
--- a/app/services/user_merger.rb
+++ b/app/services/user_merger.rb
@@ -354,7 +354,7 @@ class UserMerger
def 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.rb
index a721244c519..469acfaca9c 100644
--- a/lib/email/processor.rb
+++ b/lib/email/processor.rb
@@ -125,7 +125,7 @@ module Email
end
def 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_email
end
def log_email_process_failure(mail_string, exception)
diff --git a/lib/post_creator.rb b/lib/post_creator.rb
index 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)
end
def create_post_notice
diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb
index cd53ab61f4e..e25b9e04620 100644
--- a/lib/post_destroyer.rb
+++ b/lib/post_destroyer.rb
@@ -111,7 +111,7 @@ class PostDestroyer
counts = Post.where(post_type: Post.types[:regular], topic_id: @post.topic_id).where('post_number > 1').group(:user_id).count
counts.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)
end
end
end
@@ -347,7 +347,7 @@ class PostDestroyer
counts = Post.where(post_type: Post.types[:regular], topic_id: @post.topic_id).where('post_number > 1').group(:user_id).count
counts.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)
end
end
end
diff --git a/spec/components/concern/category_hashtag_spec.rb b/spec/components/concern/category_hashtag_spec.rb
index 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 do
end
it "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.rb
index 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 do
end
it "should escape the filename" do
- upload.update_attributes!(original_filename: ">
.png")
+ upload.update!(original_filename: ">
.png")
cpp.post_process_images
cpp.optimize_urls
diff --git a/spec/components/file_store/s3_store_spec.rb b/spec/components/file_store/s3_store_spec.rb
index 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 do
it "removes the file from s3 with the right paths" do
store.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 = stub
s3_bucket.expects(:object).with("tombstone/original/1X/#{upload.sha1}.png").returns(s3_object)
@@ -164,7 +164,7 @@ describe FileStore::S3Store do
store.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 = stub
s3_bucket.expects(:object).with("tombstone/#{path}").returns(s3_object)
@@ -183,7 +183,7 @@ describe FileStore::S3Store do
it "removes the file from s3 with the right paths" do
store.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 = stub
s3_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.rb
index 52cb47e180c..5743936241e 100644
--- a/spec/components/plugin/instance_spec.rb
+++ b/spec/components/plugin/instance_spec.rb
@@ -309,7 +309,7 @@ describe Plugin::Instance do
expect(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 do
expect(called).to eq(1)
- user.update_attributes!(username: 'some_username')
+ user.update!(username: 'some_username')
expect(called).to eq(1)
end
diff --git a/spec/components/post_merger_spec.rb b/spec/components/post_merger_spec.rb
index 250712968af..50873dd37b8 100644
--- a/spec/components/post_merger_spec.rb
+++ b/spec/components/post_merger_spec.rb
@@ -35,7 +35,7 @@ describe PostMerger do
end
it "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.rb
index f986e6d973d..02264c58182 100644
--- a/spec/components/search_spec.rb
+++ b/spec/components/search_spec.rb
@@ -286,7 +286,7 @@ describe Search do
end
it "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.rb
index 00df90f8695..bf5d17134d5 100644
--- a/spec/components/stylesheet/manager_spec.rb
+++ b/spec/components/stylesheet/manager_spec.rb
@@ -150,12 +150,12 @@ describe Stylesheet::Manager do
digest1 = 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_digest
expect(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_digest
expect(digest3).to_not eq(digest2)
diff --git a/spec/components/topic_query_spec.rb b/spec/components/topic_query_spec.rb
index ad375ed36be..97c8afd63e5 100644
--- a/spec/components/topic_query_spec.rb
+++ b/spec/components/topic_query_spec.rb
@@ -433,19 +433,19 @@ describe TopicQuery do
describe "category default sort order" do
it "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])
end
it "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])
end
it "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])
end
diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rb
index 11e1c2d29a0..b4e71e42503 100644
--- a/spec/components/topic_view_spec.rb
+++ b/spec/components/topic_view_spec.rb
@@ -634,7 +634,7 @@ describe TopicView do
context "categorized topic" do
let(: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" do
before { SiteSetting.topic_page_title_includes_category = false }
diff --git a/spec/integration/category_tag_spec.rb b/spec/integration/category_tag_spec.rb
index 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" do
context 'category allows other tags to be used' do
before do
- category_with_tags.update_attributes!(allow_global_tags: true)
+ category_with_tags.update!(allow_global_tags: true)
end
it "search can show the permitted tags" do
@@ -88,7 +88,7 @@ describe "category tag restrictions" do
end
it "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" do
context 'category allows other tags to be used' do
before do
- category.update_attributes!(allow_global_tags: true)
+ category.update!(allow_global_tags: true)
end
it 'filters tags correctly' do
@@ -148,7 +148,7 @@ describe "category tag restrictions" do
end
it "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" do
context "limit one tag from each group" do
before 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)
end
it "can restrict one tag from each group" do
diff --git a/spec/jobs/clean_up_uploads_spec.rb b/spec/jobs/clean_up_uploads_spec.rb
index 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 do
it "does not delete profile background uploads" do
profile_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 do
it "does not delete card background uploads" do
card_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.rb
index 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 do
expect(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)
end
end
diff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rb
index a3edcb97293..50b1fe93a11 100644
--- a/spec/jobs/reindex_search_spec.rb
+++ b/spec/jobs/reindex_search_spec.rb
@@ -21,7 +21,7 @@ describe Jobs::ReindexSearch do
model = Fabricate(m.to_sym)
# so that search data can be reindexed
search_data = model.send("#{m}_search_data")
- search_data.update_attributes!(version: 0)
+ search_data.update!(version: 0)
model.reload
subject.execute({})
diff --git a/spec/jobs/tl3_promotions_spec.rb b/spec/jobs/tl3_promotions_spec.rb
index 58e39dcfd50..2a13f32e660 100644
--- a/spec/jobs/tl3_promotions_spec.rb
+++ b/spec/jobs/tl3_promotions_spec.rb
@@ -4,7 +4,7 @@ describe Jobs::Tl3Promotions do
def 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.rb
index 16d0e6583a8..9131960bb36 100644
--- a/spec/jobs/user_email_spec.rb
+++ b/spec/jobs/user_email_spec.rb
@@ -34,14 +34,14 @@ describe Jobs::UserEmail do
end
it "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([])
end
context 'not emailed recently' do
before do
- user.update_attributes!(last_emailed_at: 8.days.ago)
+ user.update!(last_emailed_at: 8.days.ago)
end
it "calls the mailer when the user exists" do
@@ -52,8 +52,8 @@ describe Jobs::UserEmail do
context 'recently emailed' do
before 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)
end
it 'skips sending digest email' do
@@ -129,7 +129,7 @@ describe Jobs::UserEmail do
end
it "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 do
end
it "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([])
end
it "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 do
end
it "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.rb
index af47372859a..c7695476215 100644
--- a/spec/models/category_spec.rb
+++ b/spec/models/category_spec.rb
@@ -311,31 +311,31 @@ describe Category do
end
it "renames the definition when renamed" do
- @category.update_attributes(name: 'Troutfishing')
+ @category.update(name: 'Troutfishing')
@topic.reload
expect(@topic.title).to match(/Troutfishing/)
expect(@topic.fancy_title).to match(/Troutfishing/)
end
it "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_error
end
it "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)
end
it "reuses existing permalink when category slug is changed" do
permalink = 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)
end
it "creates permalink when sub category slug is changed" do
sub_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 do
GlobalSetting.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.last
expect(permalink.url).to eq(old_url[1..-1])
end
diff --git a/spec/models/group_history_spec.rb b/spec/models/group_history_spec.rb
index baa0e43f306..55f6de4c449 100644
--- a/spec/models/group_history_spec.rb
+++ b/spec/models/group_history_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe GroupHistory do
end
it '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 do
end
it '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.rb
index 45988094cd6..425187e4af2 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -617,7 +617,7 @@ describe Group do
it 'should cook the bio' do
group = 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")
end
diff --git a/spec/models/post_reply_spec.rb b/spec/models/post_reply_spec.rb
index d67ef33cae0..64a07ec3560 100644
--- a/spec/models/post_reply_spec.rb
+++ b/spec/models/post_reply_spec.rb
@@ -13,7 +13,7 @@ describe PostReply do
expect(PostReply.new(post: post, reply: other_post)).to be_valid
other_topic = Fabricate(:topic)
- other_post.update_attributes!(topic_id: other_topic.id)
+ other_post.update!(topic_id: other_topic.id)
other_post.reload
post_reply = PostReply.new(post: post, reply: other_post)
diff --git a/spec/models/user_search_spec.rb b/spec/models/user_search_spec.rb
index 2f4b9c484ad..4f6487d1f32 100644
--- a/spec/models/user_search_spec.rb
+++ b/spec/models/user_search_spec.rb
@@ -28,7 +28,7 @@ describe UserSearch do
Fabricate :post, user: user6, topic: topic
Fabricate :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)
end
def search_for(*args)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 94a1fb9536e..efc241a1806 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1633,14 +1633,14 @@ describe User do
describe 'when first notification has been seen' do
it '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)
end
end
describe 'when user is trust level 1' do
it '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 do
describe 'when user is trust level 2' do
it '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 do
describe 'when user is an old user' do
it '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)
end
diff --git a/spec/multisite/s3_store_spec.rb b/spec/multisite/s3_store_spec.rb
index 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 do
upload = build_upload
store.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 = stub
s3_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 do
upload = build_upload
store.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 = stub
s3_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 do
upload = build_upload
store.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 = stub
s3_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.rb
index 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 do
stat.posts_read_count = SiteSetting.tl1_requires_read_posts + 1
stat.time_read = SiteSetting.tl1_requires_time_spent_mins * 60
stat.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.rb
index f4cac122fe1..06aed4203a5 100644
--- a/spec/requests/groups_controller_spec.rb
+++ b/spec/requests/groups_controller_spec.rb
@@ -430,7 +430,7 @@ describe GroupsController do
response_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 do
context "when user is group admin" do
before do
- user.update_attributes!(admin: true)
+ user.update!(admin: true)
sign_in(user)
end
@@ -804,7 +804,7 @@ describe GroupsController do
context 'public group' do
it 'should be fobidden' do
- group.update_attributes!(
+ group.update!(
public_admission: true,
public_exit: true
)
@@ -1184,7 +1184,7 @@ describe GroupsController do
describe 'when viewing a public group' do
before 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.rb
index 22e301edb5d..13f0f7c284b 100644
--- a/spec/requests/invites_controller_spec.rb
+++ b/spec/requests/invites_controller_spec.rb
@@ -26,7 +26,7 @@ describe InvitesController do
end
it "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.rb
index afa4d58dc99..21acdd8300a 100644
--- a/spec/requests/list_controller_spec.rb
+++ b/spec/requests/list_controller_spec.rb
@@ -416,7 +416,7 @@ RSpec.describe ListController do
describe "category default views" do
it "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 do
end
it "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 do
end
it "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 do
end
it "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.rb
index 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 do
describe '#show' do
def 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"
end
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index eece747de99..da5b497d3e6 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -1668,7 +1668,7 @@ describe UsersController do
put "/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: true
put "/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.rb
index c75f55b4d1b..69486d9825b 100644
--- a/spec/services/badge_granter_spec.rb
+++ b/spec/services/badge_granter_spec.rb
@@ -266,7 +266,7 @@ describe BadgeGranter do
action = PostActionCreator.like(liker, post).post_action
# Nice post badge
- post.update_attributes like_count: 10
+ post.update like_count: 10
BadgeGranter.queue_badge_grant(Badge::Trigger::PostAction, post_action: action)
BadgeGranter.process_queue!
@@ -275,19 +275,19 @@ describe BadgeGranter do
expect(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: 25
BadgeGranter.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: 50
BadgeGranter.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: 49
BadgeGranter.backfill(Badge.find(Badge::GreatPost))
expect(UserBadge.find_by(user_id: user.id, badge_id: Badge::GreatPost)).to eq(nil)
end
diff --git a/spec/services/group_action_logger_spec.rb b/spec/services/group_action_logger_spec.rb
index 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 do
describe '#log_change_group_settings' do
it '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.rb
index 5762ffd1467..faeda4bd5c0 100644
--- a/spec/services/search_indexer_spec.rb
+++ b/spec/services/search_indexer_spec.rb
@@ -75,7 +75,7 @@ describe SearchIndexer do
it 'correctly indexes a post according to version' do
# Preparing so that they can be indexed to right version
SearchIndexer.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 = "This 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.rb
index afeb76beaa2..da19ae94c98 100644
--- a/spec/services/user_anonymizer_spec.rb
+++ b/spec/services/user_anonymizer_spec.rb
@@ -72,10 +72,10 @@ describe UserAnonymizer do
end
it "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 do
it "changes name to anonymized username" do
prev_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_anonymous
user.reload
diff --git a/spec/services/user_updater_spec.rb b/spec/services/user_updater_spec.rb
index 31a8ca78961..f7db5982d75 100644
--- a/spec/services/user_updater_spec.rb
+++ b/spec/services/user_updater_spec.rb
@@ -258,7 +258,7 @@ describe UserUpdater do
context 'badge can be used as a title' do
before do
- badge.update_attributes(allow_title: true)
+ badge.update(allow_title: true)
end
it 'can use as title, sets badge_granted_title' do
@@ -270,7 +270,7 @@ describe UserUpdater do
end
it '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 do
end
it '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 = stub
guardian.stubs(:can_grant_title?).with(user, 'Dancer').returns(true)
diff --git a/spec/tasks/posts_spec.rb b/spec/tasks/posts_spec.rb
index 5631919fd21..a0cbe9338cd 100644
--- a/spec/tasks/posts_spec.rb
+++ b/spec/tasks/posts_spec.rb
@@ -45,7 +45,7 @@ RSpec.describe "Post rake tasks" do
describe 'rebake_match' do
it 'rebakes matched posts' do
- post.update_attributes(cooked: '')
+ post.update(cooked: '')
HighLine::Simulate.with('y') do
Rake::Task['posts:rebake_match'].invoke('brown')