Unify flaggable specs

This commit is contained in:
taitus
2023-12-21 10:56:16 +01:00
parent f328d53f41
commit 3f1561e408
8 changed files with 16 additions and 36 deletions

View File

@@ -5,7 +5,7 @@ FactoryBot.define do
sequence(:body) { |n| "Comment body #{n}" } sequence(:body) { |n| "Comment body #{n}" }
%i[budget_investment debate legislation_annotation legislation_question legislation_proposal %i[budget_investment debate legislation_annotation legislation_question legislation_proposal
poll proposal topic_with_community].each do |model| poll proposal topic_with_community topic_with_investment_community].each do |model|
factory :"#{model}_comment" do factory :"#{model}_comment" do
commentable factory: model commentable factory: model
end end

View File

@@ -3,8 +3,6 @@ require "rails_helper"
describe "Commenting Budget::Investments" do describe "Commenting Budget::Investments" do
let(:investment) { create(:budget_investment) } let(:investment) { create(:budget_investment) }
it_behaves_like "flaggable", :budget_investment_comment
describe "Administrators" do describe "Administrators" do
context "comment as administrator" do context "comment as administrator" do
scenario "display administrator description on admin views" do scenario "display administrator description on admin views" do

View File

@@ -1,5 +0,0 @@
require "rails_helper"
describe "Commenting debates" do
it_behaves_like "flaggable", :debate_comment
end

View File

@@ -4,8 +4,6 @@ describe "Commenting legislation questions" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:annotation) { create(:legislation_annotation, author: user) } let(:annotation) { create(:legislation_annotation, author: user) }
it_behaves_like "flaggable", :legislation_annotation_comment
describe "Merged comment threads" do describe "Merged comment threads" do
let!(:draft_version) { create(:legislation_draft_version, :published) } let!(:draft_version) { create(:legislation_draft_version, :published) }
let!(:annotation1) do let!(:annotation1) do

View File

@@ -1,8 +1,5 @@
require "rails_helper" require "rails_helper"
describe "Commenting legislation questions" do describe "Commenting legislation questions" do
context "Concerns" do it_behaves_like "notifiable in-app", :legislation_question
it_behaves_like "notifiable in-app", :legislation_question
it_behaves_like "flaggable", :legislation_question_comment
end
end end

View File

@@ -1,5 +0,0 @@
require "rails_helper"
describe "Commenting proposals" do
it_behaves_like "flaggable", :proposal_comment
end

View File

@@ -1,5 +0,0 @@
require "rails_helper"
describe "Commenting topics from proposals" do
it_behaves_like "flaggable", :topic_with_community_comment
end

View File

@@ -1,18 +1,18 @@
require "rails_helper" require "rails_helper"
describe "Comments" do describe "Comments" do
let(:factory) { factories = [
[ :budget_investment,
:budget_investment, :debate,
:debate, :legislation_annotation,
:legislation_annotation, :legislation_question,
:legislation_question, :poll_with_author,
:poll_with_author, :proposal,
:proposal, :topic_with_community,
:topic_with_community, :topic_with_investment_community
:topic_with_investment_community ]
].sample
} let(:factory) { factories.sample }
let(:resource) { create(factory) } let(:resource) { create(factory) }
let(:user) do let(:user) do
if factory == :legislation_question if factory == :legislation_question
@@ -36,6 +36,8 @@ describe "Comments" do
end end
end end
it_behaves_like "flaggable", :"#{(factories - [:poll_with_author]).sample}_comment"
describe "Index" do describe "Index" do
context "Budget Investments" do context "Budget Investments" do
let(:investment) { create(:budget_investment) } let(:investment) { create(:budget_investment) }