From 911d47934a957fd1db1024afed6cb06ccd6d6229 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 24 Sep 2020 09:56:09 +0800 Subject: [PATCH] DEV: Prefer `update!` over `update` when return value is not checked. --- spec/requests/topics_controller_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spec/requests/topics_controller_spec.rb b/spec/requests/topics_controller_spec.rb index 117c88b7a69..4229bce9fff 100644 --- a/spec/requests/topics_controller_spec.rb +++ b/spec/requests/topics_controller_spec.rb @@ -1280,18 +1280,19 @@ RSpec.describe TopicsController do describe "when first post is locked" do it "blocks non-staff from editing even if 'trusted_users_can_edit_others' is true" do SiteSetting.trusted_users_can_edit_others = true - user.update(trust_level: 3) - topic.first_post.update(locked_by_id: admin.id) + user.update!(trust_level: 3) + topic.first_post.update!(locked_by_id: admin.id) put "/t/#{topic.slug}/#{topic.id}.json", params: { title: topic.title + " hello" } + expect(response.status).to eq(403) end it "allows staff to edit" do sign_in(Fabricate(:admin)) - topic.first_post.update(locked_by_id: admin.id) + topic.first_post.update!(locked_by_id: admin.id) put "/t/#{topic.slug}/#{topic.id}.json", params: { title: topic.title + " hello"