Skip to content

Commit

Permalink
add checks to comments_example
Browse files Browse the repository at this point in the history
  • Loading branch information
ElviaBth committed Jun 26, 2024
1 parent b03257a commit b11b47d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
10 changes: 4 additions & 6 deletions decidim-comments/spec/forms/comment_form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ module Comments
attributes
).with_context(
current_organization: organization,
current_component: component
current_component: component,
current_user: user
)
end

let(:organization) { create(:organization) }
let(:user) { create(:user, :confirmed, organization:) }
let(:admin_user) { create(:user, :admin, :confirmed, organization:) }
let(:user_manager) { create(:user, :user_manager, :confirmed, organization:) }
let!(:component) { create(:component, organization:) }
Expand All @@ -23,7 +25,7 @@ module Comments
let(:user_group) { create(:user_group, :verified) }
let(:user_group_id) { user_group.id }

let(:commentable) { create(:dummy_resource, accepts_new_comments?: false) }
let(:commentable) { create(:dummy_resource) }

let(:attributes) do
{
Expand Down Expand Up @@ -114,10 +116,6 @@ module Comments
end

describe "#commentable_can_have_comments" do
before do
allow(subject).to receive(:current_user).and_return(current_user)
end

context "when user is admin" do
let(:current_user) { admin_user }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,19 @@

it_behaves_like "can answer comments"
end

context "when the user has a role of user manager" do
let!(:user) { create(:user, :user_manager, :confirmed, organization:) }

it_behaves_like "can answer comments"
end

context "when the user has an evaluator role" do
let!(:participatory_process) { create(:participatory_process, :with_steps, organization:) }
let!(:valuator_role) { create(:participatory_process_user_role, role: :valuator, user:, participatory_process:) }

it_behaves_like "can answer comments"
end
end
end
end

0 comments on commit b11b47d

Please sign in to comment.