docbrown/spec/helpers/moderations/actions_panel_helper_spec.rb
Ridhwana aa201060e8
Override Tag Moderation Actions (#20088)
* feat: remove the validation for the article_id and tag_name to be unique on a tag_adjustment

* chore: remove unique index

* feat: update the validate_tag method to align with the removal of unique indexes on the table

* feat: do not allow removal and addition of tags that were added/removed by admins

* spec: add tests for the tag_adjustment_spec

* fix: update the validation of tags

* spec: article validation

* spec: test the action_panel helper

* chore: amend language

* add styles

* Empty commit
2023-09-15 15:06:58 +02:00

26 lines
1 KiB
Ruby

require "rails_helper"
describe Moderations::ActionsPanelHelper do
describe "#last_adjusted_by_admin?" do
let(:tag1) { create(:tag) }
let(:tag2) { create(:tag, name: "tag2") }
let(:admin) { create(:user, :admin) }
let(:user) { create(:user) }
let(:article) { create(:article, tags: "tag2") }
it "returns false if the last adjustment was made by a non-admin" do
user.add_role(:tag_moderator, tag2)
create(:tag_adjustment, article: article, tag_id: tag2.id, tag_name: tag2.name, user: user,
status: "committed", adjustment_type: "removal")
expect(helper.last_adjusted_by_admin?(article, tag2, "removal")).to be(false)
end
it "returns true if the last adjustment was made by any admin" do
create(:tag_adjustment, article: article, tag_id: tag1.id, tag_name: tag1.name, user: admin,
status: "committed", adjustment_type: "addition")
expect(helper.last_adjusted_by_admin?(article, tag1, "addition")).to be(true)
end
end
end