A platform for community discussion. Free, open, simple.
FIX: Also check if user can see post or topic prior to letting them localize it (#36749)
Natalie Tay71b96243e197
diff --git a/app/controllers/post_localizations_controller.rb b/app/controllers/post_localizations_controller.rbindex 37976e45142..919638a7404 100644--- a/app/controllers/post_localizations_controller.rb+++ b/app/controllers/post_localizations_controller.rb@@ -39,14 +39,17 @@ class PostLocalizationsController < ApplicationControllerdef create_or_updatepost_id, locale, raw = params.require(%i[post_id locale raw])- guardian.ensure_can_localize_post!(post_id)+ post = Post.find_by(id: post_id)+ raise Discourse::NotFound unless post++ guardian.ensure_can_localize_post!(post)- localization = PostLocalization.find_by(post_id:, locale:)+ localization = PostLocalization.find_by(post_id: post.id, locale:)if localization- PostLocalizationUpdater.update(post_id: post_id, locale:, raw:, user: current_user)+ PostLocalizationUpdater.update(post:, locale:, raw:, user: current_user)render json: success_json, status: :okelse- PostLocalizationCreator.create(post_id: post_id, locale:, raw:, user: current_user)+ PostLocalizationCreator.create(post:, locale:, raw:, user: current_user)render json: success_json, status: :createdendend@@ -54,9 +57,12 @@ class PostLocalizationsController < ApplicationControllerdef destroypost_id, locale = params.require(%i[post_id locale])- guardian.ensure_can_localize_post!(post_id)+ post = Post.find_by(id: post_id)+ raise Discourse::NotFound unless post++ guardian.ensure_can_localize_post!(post)- PostLocalizationDestroyer.destroy(post_id:, locale:, acting_user: current_user)+ PostLocalizationDestroyer.destroy(post:, locale:, acting_user: current_user)head :no_contentendenddiff --git a/app/controllers/topic_localizations_controller.rb b/app/controllers/topic_localizations_controller.rbindex 73bae61be79..7bc7047f541 100644--- a/app/controllers/topic_localizations_controller.rb+++ b/app/controllers/topic_localizations_controller.rb@@ -6,19 +6,22 @@ class TopicLocalizationsController < ApplicationControllerdef create_or_updatetopic_id, locale, title = params.require(%i[topic_id locale title])- guardian.ensure_can_localize_topic!(topic_id)+ topic = Topic.find_by(id: topic_id)+ raise Discourse::NotFound unless topic- topic_localization = TopicLocalization.find_by(topic_id: topic_id, locale: params[:locale])+ guardian.ensure_can_localize_topic!(topic)++ topic_localization = TopicLocalization.find_by(topic_id: topic.id, locale: params[:locale])if topic_localizationTopicLocalizationUpdater.update(- topic_id: topic_id,+ topic:,locale: params[:locale],title: params[:title],user: current_user,)render json: success_json, status: :okelse- TopicLocalizationCreator.create(topic_id:, locale:, title:, user: current_user)+ TopicLocalizationCreator.create(topic:, locale:, title:, user: current_user)render json: success_json, status: :createdendend@@ -26,9 +29,12 @@ class TopicLocalizationsController < ApplicationControllerdef destroytopic_id, locale = params.require(%i[topic_id locale])- guardian.ensure_can_localize_topic!(topic_id)+ topic = Topic.find_by(id: topic_id)+ raise Discourse::NotFound unless topic++ guardian.ensure_can_localize_topic!(topic)- TopicLocalizationDestroyer.destroy(topic_id:, locale:, acting_user: current_user)+ TopicLocalizationDestroyer.destroy(topic:, locale:, acting_user: current_user)head :no_contentendenddiff --git a/lib/guardian/localization_guardian.rb b/lib/guardian/localization_guardian.rbindex 4b695e44d08..e95a6a518f5 100644--- a/lib/guardian/localization_guardian.rb+++ b/lib/guardian/localization_guardian.rb@@ -13,22 +13,26 @@ module LocalizationGuardianreturn false if !SiteSetting.content_localization_enabledreturn false if anonymous?+ post = post_or_post_id.is_a?(Post) ? post_or_post_id : Post.find_by(id: post_or_post_id)+ return false if !can_see_post?(post)+return true if @user.in_any_groups?(SiteSetting.content_localization_allowed_groups_map)return false if !SiteSetting.content_localization_allow_author_localization- post = post_or_post_id.is_a?(Post) ? post_or_post_id : Post.find_by(id: post_or_post_id)- post&.user_id == @user.id+ post.user_id == @user.idenddef can_localize_topic?(topic_or_topic_id)return false if !SiteSetting.content_localization_enabledreturn false if anonymous?+ topic =+ topic_or_topic_id.is_a?(Topic) ? topic_or_topic_id : Topic.find_by(id: topic_or_topic_id)+ return false if !can_see_topic?(topic)+return true if @user.in_any_groups?(SiteSetting.content_localization_allowed_groups_map)return false if !SiteSetting.content_localization_allow_author_localization- topic =- topic_or_topic_id.is_a?(Topic) ? topic_or_topic_id : Topic.find_by(id: topic_or_topic_id)- topic&.user_id == @user.id+ topic.user_id == @user.idendenddiff --git a/lib/post_localization_creator.rb b/lib/post_localization_creator.rbindex 6bdb8e8c046..fc2e976032c 100644--- a/lib/post_localization_creator.rb+++ b/lib/post_localization_creator.rb@@ -1,11 +1,8 @@# frozen_string_literal: trueclass PostLocalizationCreator- def self.create(post_id:, locale:, raw:, user:)- post = Post.find_by(id: post_id)-+ def self.create(post:, locale:, raw:, user:)Guardian.new(user).ensure_can_localize_post!(post)- raise Discourse::NotFound unless postlocalization =PostLocalization.create!(diff --git a/lib/post_localization_destroyer.rb b/lib/post_localization_destroyer.rbindex 01cef3b89ec..c4f0eebe058 100644--- a/lib/post_localization_destroyer.rb+++ b/lib/post_localization_destroyer.rb@@ -1,15 +1,13 @@# frozen_string_literal: trueclass PostLocalizationDestroyer- def self.destroy(post_id:, locale:, acting_user:)- Guardian.new(acting_user).ensure_can_localize_post!(post_id)+ def self.destroy(post:, locale:, acting_user:)+ Guardian.new(acting_user).ensure_can_localize_post!(post)- localization = PostLocalization.find_by(post_id:, locale:)+ localization = PostLocalization.find_by(post_id: post.id, locale:)raise Discourse::NotFound unless localizationlocalization.destroy!-- post = localization.post- post.publish_change_to_clients! :revised if post+ post.publish_change_to_clients! :revisedendenddiff --git a/lib/post_localization_updater.rb b/lib/post_localization_updater.rbindex 026543e533b..2e3eff4df7f 100644--- a/lib/post_localization_updater.rb+++ b/lib/post_localization_updater.rb@@ -1,13 +1,11 @@# frozen_string_literal: trueclass PostLocalizationUpdater- def self.update(post_id:, locale:, raw:, user:)- Guardian.new(user).ensure_can_localize_post!(post_id)+ def self.update(post:, locale:, raw:, user:)+ Guardian.new(user).ensure_can_localize_post!(post)- localization = PostLocalization.find_by(post_id: post_id, locale: locale)+ localization = PostLocalization.find_by(post_id: post.id, locale: locale)raise Discourse::NotFound unless localization- post = localization.post- raise Discourse::NotFound unless postreturn localization if localization.raw == rawdiff --git a/lib/topic_localization_creator.rb b/lib/topic_localization_creator.rbindex ae6e7ae0237..0ef3b227413 100644--- a/lib/topic_localization_creator.rb+++ b/lib/topic_localization_creator.rb@@ -1,11 +1,11 @@# frozen_string_literal: trueclass TopicLocalizationCreator- def self.create(topic_id:, locale:, title:, user:)- Guardian.new(user).ensure_can_localize_topic!(topic_id)+ def self.create(topic:, locale:, title:, user:)+ Guardian.new(user).ensure_can_localize_topic!(topic)TopicLocalization.create!(- topic_id: topic_id,+ topic_id: topic.id,locale: locale,title: title,fancy_title: Topic.fancy_title(title),diff --git a/lib/topic_localization_destroyer.rb b/lib/topic_localization_destroyer.rbindex 8a01a40641c..ddc976d7007 100644--- a/lib/topic_localization_destroyer.rb+++ b/lib/topic_localization_destroyer.rb@@ -1,10 +1,10 @@# frozen_string_literal: trueclass TopicLocalizationDestroyer- def self.destroy(topic_id:, locale:, acting_user:)- Guardian.new(acting_user).ensure_can_localize_topic!(topic_id)+ def self.destroy(topic:, locale:, acting_user:)+ Guardian.new(acting_user).ensure_can_localize_topic!(topic)- localization = TopicLocalization.find_by(topic_id: topic_id, locale: locale)+ localization = TopicLocalization.find_by(topic_id: topic.id, locale: locale)raise Discourse::NotFound unless localizationlocalization.destroydiff --git a/lib/topic_localization_updater.rb b/lib/topic_localization_updater.rbindex f0479ed2216..821f0ec93b7 100644--- a/lib/topic_localization_updater.rb+++ b/lib/topic_localization_updater.rb@@ -1,10 +1,10 @@# frozen_string_literal: trueclass TopicLocalizationUpdater- def self.update(topic_id:, locale:, title:, user:)- Guardian.new(user).ensure_can_localize_topic!(topic_id)+ def self.update(topic:, locale:, title:, user:)+ Guardian.new(user).ensure_can_localize_topic!(topic)- localization = TopicLocalization.find_by(topic_id: topic_id, locale: locale)+ localization = TopicLocalization.find_by(topic_id: topic.id, locale: locale)raise Discourse::NotFound unless localizationreturn localization if localization.title == titlediff --git a/spec/lib/guardian/localization_guardian_spec.rb b/spec/lib/guardian/localization_guardian_spec.rbindex 0cda32f2974..1849c2fa658 100644--- a/spec/lib/guardian/localization_guardian_spec.rb+++ b/spec/lib/guardian/localization_guardian_spec.rb@@ -34,6 +34,32 @@ describe LocalizationGuardian doexpect(Guardian.new(user).can_localize_post?(post)).to eq(false)end+ context "when user cannot see the post" do+ fab!(:private_category) { Fabricate(:private_category, group: Fabricate(:group)) }+ fab!(:private_topic) { Fabricate(:topic, category: private_category) }+ fab!(:private_post) { Fabricate(:post, topic: private_topic) }++ before do+ SiteSetting.content_localization_allowed_groups = "#{Group::AUTO_GROUPS[:everyone]}"+ end++ it "returns false for posts in private categories the user cannot access" do+ expect(Guardian.new(user).can_localize_post?(private_post)).to eq(false)+ expect(Guardian.new(user).can_localize_post?(private_post.id)).to eq(false)+ end++ it "returns false for posts in private messages the user is not part of" do+ pm = Fabricate(:private_message_topic)+ pm_post = Fabricate(:post, topic: pm)+ expect(Guardian.new(user).can_localize_post?(pm_post)).to eq(false)+ expect(Guardian.new(user).can_localize_post?(pm_post.id)).to eq(false)+ end++ it "returns false for non-existent posts" do+ expect(Guardian.new(user).can_localize_post?(999_999_999)).to eq(false)+ end+ end+context "when user is in allowed groups" dobefore { SiteSetting.content_localization_allowed_groups = "#{Group::AUTO_GROUPS[:admins]}" }@@ -93,6 +119,30 @@ describe LocalizationGuardian doexpect(Guardian.new(user).can_localize_topic?(topic)).to eq(false)end+ context "when user cannot see the topic" do+ fab!(:private_category) { Fabricate(:private_category, group: Fabricate(:group)) }+ fab!(:private_topic) { Fabricate(:topic, category: private_category) }++ before do+ SiteSetting.content_localization_allowed_groups = "#{Group::AUTO_GROUPS[:everyone]}"+ end++ it "returns false for topics in private categories the user cannot access" do+ expect(Guardian.new(user).can_localize_topic?(private_topic)).to eq(false)+ expect(Guardian.new(user).can_localize_topic?(private_topic.id)).to eq(false)+ end++ it "returns false for private messages the user is not part of" do+ pm = Fabricate(:private_message_topic)+ expect(Guardian.new(user).can_localize_topic?(pm)).to eq(false)+ expect(Guardian.new(user).can_localize_topic?(pm.id)).to eq(false)+ end++ it "returns false for non-existent topics" do+ expect(Guardian.new(user).can_localize_topic?(999_999_999)).to eq(false)+ end+ end+context "when user is in allowed groups" dobefore { SiteSetting.content_localization_allowed_groups = "#{Group::AUTO_GROUPS[:admins]}" }diff --git a/spec/lib/post_localization_creator_spec.rb b/spec/lib/post_localization_creator_spec.rbindex 449937c8e4c..870301945d3 100644--- a/spec/lib/post_localization_creator_spec.rb+++ b/spec/lib/post_localization_creator_spec.rb@@ -15,7 +15,7 @@ describe PostLocalizationCreator doendit "creates a post localization record" do- localization = described_class.create(post_id: post.id, locale:, raw:, user:)+ localization = described_class.create(post:, locale:, raw:, user:)expect(PostLocalization.find(localization.id)).to have_attributes(post_id: post.id,@@ -27,17 +27,11 @@ describe PostLocalizationCreator doendit "enqueues ProcessLocalizedCook job" do- loc = described_class.create(post_id: post.id, locale:, raw:, user:)+ loc = described_class.create(post:, locale:, raw:, user:)expect_job_enqueued(job: :process_localized_cooked, args: { post_localization_id: loc.id })end- it "raises not found if the post is missing" do- expect { described_class.create(post_id: -1, locale:, raw:, user:) }.to raise_error(- Discourse::NotFound,- )- end-context "with author localization" dofab!(:author, :user)fab!(:author_post) { Fabricate(:post, user: author) }@@ -46,7 +40,7 @@ describe PostLocalizationCreator dobefore { SiteSetting.content_localization_allow_author_localization = true }it "allows post author to create localization for their own post" do- localization = described_class.create(post_id: author_post.id, locale:, raw:, user: author)+ localization = described_class.create(post: author_post, locale:, raw:, user: author)expect(localization).to have_attributes(post_id: author_post.id,@@ -58,7 +52,7 @@ describe PostLocalizationCreator doit "raises permission error if user is not the post author" doexpect {- described_class.create(post_id: other_post.id, locale:, raw:, user: author)+ described_class.create(post: other_post, locale:, raw:, user: author)}.to raise_error(Discourse::InvalidAccess)endenddiff --git a/spec/lib/post_localization_destroyer_spec.rb b/spec/lib/post_localization_destroyer_spec.rbindex 93efb07b7b6..576a3507077 100644--- a/spec/lib/post_localization_destroyer_spec.rb+++ b/spec/lib/post_localization_destroyer_spec.rb@@ -15,22 +15,22 @@ describe PostLocalizationDestroyer doendit "deletes the localization" do- expect {- described_class.destroy(post_id: post.id, locale: locale, acting_user: user)- }.to change { PostLocalization.count }.by(-1)+ expect { described_class.destroy(post:, locale:, acting_user: user) }.to change {+ PostLocalization.count+ }.by(-1)expect { PostLocalization.find(localization.id) }.to raise_error(ActiveRecord::RecordNotFound)endit "raises not found if the localization is missing" do- expect {- described_class.destroy(post_id: post.id, locale: "nope", acting_user: user)- }.to raise_error(Discourse::NotFound)+ expect { described_class.destroy(post:, locale: "nope", acting_user: user) }.to raise_error(+ Discourse::NotFound,+ )endit "publishes MessageBus notification" domessages =MessageBus.track_publish("/topic/#{post.topic_id}") do- described_class.destroy(post_id: post.id, locale: locale, acting_user: user)+ described_class.destroy(post:, locale:, acting_user: user)endexpect(messages.length).to eq(1)@@ -46,15 +46,15 @@ describe PostLocalizationDestroyer dobefore { SiteSetting.content_localization_allow_author_localization = true }- it "allows post author to create localization for their own post" do- localization = described_class.destroy(post_id: author_post.id, locale:, acting_user: author)+ it "allows post author to destroy localization for their own post" do+ localization = described_class.destroy(post: author_post, locale:, acting_user: author)expect(localization).to be_nilendit "raises permission error if user is not the post author" doexpect {- described_class.destroy(post_id: other_post.id, locale:, acting_user: author)+ described_class.destroy(post: other_post, locale:, acting_user: author)}.to raise_error(Discourse::InvalidAccess)endenddiff --git a/spec/lib/post_localization_updater_spec.rb b/spec/lib/post_localization_updater_spec.rbindex c9fa1328ac7..1b9db91e653 100644--- a/spec/lib/post_localization_updater_spec.rb+++ b/spec/lib/post_localization_updater_spec.rb@@ -18,8 +18,7 @@ describe PostLocalizationUpdater doendit "updates an existing localization" do- localization =- described_class.update(post_id: post.id, locale: locale, raw: new_raw, user: user)+ localization = described_class.update(post:, locale:, raw: new_raw, user:)expect(localization).to have_attributes(raw: new_raw,@@ -30,29 +29,22 @@ describe PostLocalizationUpdater doendit "returns the localization unchanged if the raw content is the same" do- localization =- described_class.update(post_id: post.id, locale:, raw: post_localization.raw, user:)+ localization = described_class.update(post:, locale:, raw: post_localization.raw, user:)expect(localization.id).to eq(post_localization.id)expect(localization.localizer_user_id).not_to eq(user.id)endit "enqueues ProcessLocalizedCook job" do- loc = described_class.update(post_id: post.id, locale: locale, raw: new_raw, user: user)+ loc = described_class.update(post:, locale:, raw: new_raw, user:)expect_job_enqueued(job: :process_localized_cooked, args: { post_localization_id: loc.id })endit "raises not found if the localization is missing" do- expect {- described_class.update(post_id: post.id, locale: "nope", raw: new_raw, user: user)- }.to raise_error(Discourse::NotFound)- end-- it "raises not found if the post is missing" do- expect {- described_class.update(post_id: -1, locale: locale, raw: new_raw, user: user)- }.to raise_error(Discourse::NotFound)+ expect { described_class.update(post:, locale: "nope", raw: new_raw, user:) }.to raise_error(+ Discourse::NotFound,+ )endcontext "with author localization" do@@ -64,8 +56,7 @@ describe PostLocalizationUpdater dobefore { SiteSetting.content_localization_allow_author_localization = true }it "allows post author to create localization for their own post" do- localization =- described_class.update(post_id: author_post.id, locale:, raw: new_raw, user: author)+ localization = described_class.update(post: author_post, locale:, raw: new_raw, user: author)expect(localization).to have_attributes(post_id: author_post.id,@@ -77,7 +68,7 @@ describe PostLocalizationUpdater doit "raises permission error if user is not the post author" doexpect {- described_class.update(post_id: other_post.id, locale:, raw: new_raw, user: author)+ described_class.update(post: other_post, locale:, raw: new_raw, user: author)}.to raise_error(Discourse::InvalidAccess)endenddiff --git a/spec/lib/topic_localization_creator_spec.rb b/spec/lib/topic_localization_creator_spec.rbindex 9f2e09a05de..b3f821ddb6e 100644--- a/spec/lib/topic_localization_creator_spec.rb+++ b/spec/lib/topic_localization_creator_spec.rb@@ -15,7 +15,7 @@ describe TopicLocalizationCreator doendit "creates a topic localization record" do- localization = described_class.create(topic_id: topic.id, locale:, title:, user:)+ localization = described_class.create(topic:, locale:, title:, user:)expect(TopicLocalization.find(localization.id)).to have_attributes(topic_id: topic.id,@@ -28,7 +28,7 @@ describe TopicLocalizationCreator doit "raises permission error if user not in allowed groups" dogroup.remove(user)- expect { described_class.create(topic_id: topic.id, locale:, title:, user:) }.to raise_error(+ expect { described_class.create(topic:, locale:, title:, user:) }.to raise_error(Discourse::InvalidAccess,)end@@ -44,8 +44,7 @@ describe TopicLocalizationCreator doendit "allows topic author to create localization for their own topic" do- localization =- described_class.create(topic_id: author_topic.id, locale:, title:, user: author)+ localization = described_class.create(topic: author_topic, locale:, title:, user: author)expect(localization).to have_attributes(topic_id: author_topic.id,@@ -57,7 +56,7 @@ describe TopicLocalizationCreator doit "raises permission error if user is not the topic author" doexpect {- described_class.create(topic_id: other_topic.id, locale:, title:, user: author)+ described_class.create(topic: other_topic, locale:, title:, user: author)}.to raise_error(Discourse::InvalidAccess)endenddiff --git a/spec/lib/topic_localization_destroyer_spec.rb b/spec/lib/topic_localization_destroyer_spec.rbindex baed59df6ad..1e575f5da86 100644--- a/spec/lib/topic_localization_destroyer_spec.rb+++ b/spec/lib/topic_localization_destroyer_spec.rb@@ -15,23 +15,23 @@ describe TopicLocalizationDestroyer doendit "deletes the localization" do- expect {- described_class.destroy(topic_id: topic.id, locale: locale, acting_user: user)- }.to change { TopicLocalization.count }.by(-1)+ expect { described_class.destroy(topic:, locale:, acting_user: user) }.to change {+ TopicLocalization.count+ }.by(-1)expect { TopicLocalization.find(localization.id) }.to raise_error(ActiveRecord::RecordNotFound)endit "raises not found if the localization is missing" do- expect {- described_class.destroy(topic_id: topic.id, locale: "nope", acting_user: user)- }.to raise_error(Discourse::NotFound)+ expect { described_class.destroy(topic:, locale: "nope", acting_user: user) }.to raise_error(+ Discourse::NotFound,+ )endit "raises permission error if user not in allowed groups" dogroup.remove(user)- expect {- described_class.destroy(topic_id: topic.id, locale: locale, acting_user: user)- }.to raise_error(Discourse::InvalidAccess)+ expect { described_class.destroy(topic:, locale:, acting_user: user) }.to raise_error(+ Discourse::InvalidAccess,+ )endcontext "with author localization" do@@ -46,7 +46,7 @@ describe TopicLocalizationDestroyer doit "allows topic author to destroy localization for their own topic" doexpect {- described_class.destroy(topic_id: author_topic.id, locale: "ja", acting_user: author)+ described_class.destroy(topic: author_topic, locale: "ja", acting_user: author)}.to change { TopicLocalization.count }.by(-1)expect { TopicLocalization.find(author_localization.id) }.to raise_error(ActiveRecord::RecordNotFound,@@ -54,9 +54,9 @@ describe TopicLocalizationDestroyer doendit "raises permission error if user is not the topic author" do- expect {- described_class.destroy(topic_id: topic.id, locale: locale, acting_user: author)- }.to raise_error(Discourse::InvalidAccess)+ expect { described_class.destroy(topic:, locale:, acting_user: author) }.to raise_error(+ Discourse::InvalidAccess,+ )endendenddiff --git a/spec/lib/topic_localization_updater_spec.rb b/spec/lib/topic_localization_updater_spec.rbindex 763fba19838..2b1df302418 100644--- a/spec/lib/topic_localization_updater_spec.rb+++ b/spec/lib/topic_localization_updater_spec.rb@@ -18,8 +18,7 @@ describe TopicLocalizationUpdater doendit "updates an existing localization" do- localization =- described_class.update(topic_id: topic.id, locale: locale, title: new_title, user: user)+ localization = described_class.update(topic:, locale:, title: new_title, user:)expect(localization).to have_attributes(title: new_title,@@ -29,8 +28,7 @@ describe TopicLocalizationUpdater doendit "returns the localization unchanged if the title is the same" do- localization =- described_class.update(topic_id: topic.id, locale:, title: topic_localization.title, user:)+ localization = described_class.update(topic:, locale:, title: topic_localization.title, user:)expect(localization.id).to eq(topic_localization.id)expect(localization.localizer_user_id).not_to eq(user.id)@@ -38,21 +36,15 @@ describe TopicLocalizationUpdater doit "raises not found if the localization is missing" doexpect {- described_class.update(topic_id: topic.id, locale: "nope", title: new_title, user: user)- }.to raise_error(Discourse::NotFound)- end-- it "raises not found if the topic is missing" do- expect {- described_class.update(topic_id: -1, locale: locale, title: new_title, user: user)+ described_class.update(topic:, locale: "nope", title: new_title, user:)}.to raise_error(Discourse::NotFound)endit "raises permission error if user not in allowed groups" dogroup.remove(user)- expect {- described_class.update(topic_id: topic.id, locale: locale, title: new_title, user: user)- }.to raise_error(Discourse::InvalidAccess)+ expect { described_class.update(topic:, locale:, title: new_title, user:) }.to raise_error(+ Discourse::InvalidAccess,+ )endcontext "with author localization" do@@ -69,12 +61,7 @@ describe TopicLocalizationUpdater doit "allows topic author to update localization for their own topic" dolocalization =- described_class.update(- topic_id: author_topic.id,- locale: "ja",- title: new_title,- user: author,- )+ described_class.update(topic: author_topic, locale: "ja", title: new_title, user: author)expect(localization).to have_attributes(title: new_title,@@ -85,7 +72,7 @@ describe TopicLocalizationUpdater doit "raises permission error if user is not the topic author" doexpect {- described_class.update(topic_id: topic.id, locale: locale, title: new_title, user: author)+ described_class.update(topic:, locale:, title: new_title, user: author)}.to raise_error(Discourse::InvalidAccess)endend