Sha256: 9cb9ddc76ca73cf9f89b22f15530ee174e3733c6dd033927d228daa9a2ef63b3

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

shared_examples "comments_reports" do
  context "when the user is not logged in" do
    it "gives the option to sign in" do
      visit reportable_path

      # Open toolbar
      page.find("[id^='dropdown-trigger']").click
      click_on "Report"

      expect(page).to have_css("#loginModal", visible: :visible)
    end
  end

  context "when the user is logged in" do
    before do
      login_as user, scope: :user
    end

    context "and the user has not reported the resource yet" do
      it "reports the resource" do
        visit reportable_path

        # Open toolbar
        page.find("[id^='dropdown-trigger']").click
        click_on "Report"

        expect(page).to have_css(".flag-modal", visible: :visible)

        within ".flag-modal" do
          click_on "Report"
        end

        expect(page).to have_content "report has been created"
      end
    end

    context "and the user has reported the resource previously" do
      before do
        moderation = create(:moderation, reportable:, participatory_space: participatory_process)
        create(:report, moderation:, user:, reason: "spam")
      end

      it "cannot report it twice" do
        visit reportable_path

        # Open toolbar
        page.find("[id^='dropdown-trigger']").click
        click_on "Report"

        expect(page).to have_css(".flag-modal", visible: :visible)

        expect(page).to have_content "already reported"
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
decidim-core-0.30.0.rc2 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.30.0.rc1 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.29.2 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.29.1 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.29.0 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.29.0.rc4 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.29.0.rc3 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.29.0.rc2 lib/decidim/core/test/shared_examples/comments_reports_examples.rb
decidim-core-0.29.0.rc1 lib/decidim/core/test/shared_examples/comments_reports_examples.rb