Sha256: c9e034ba0b4244a4d07e586d1677bb5d3f0a3b448b8ecf1283504d3b7dc76961

Contents?: true

Size: 1.57 KB

Versions: 29

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

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

      expect(page).to have_no_css("body.is-reveal-open")

      click_button "Report"

      expect(page).to have_css("body.is-reveal-open")
    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

        expect(page).to have_selector(".author-data__extra")

        within ".author-data__extra", match: :first do
          page.find("button").click
        end

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

        within ".flag-modal" do
          click_button "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: reportable, participatory_space: participatory_process)
        create(:report, moderation: moderation, user: user, reason: "spam")
      end

      it "cannot report it twice" do
        visit reportable_path

        expect(page).to have_selector(".author-data__extra")

        within ".author-data__extra", match: :first do
          page.find("button").click
        end

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

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

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
decidim-core-0.21.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.20.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.20.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.19.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.18.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.19.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.17.2 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.18.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.17.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.16.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.17.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.16.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.15.2 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.15.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.15.0 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.14.4 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.14.3 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.14.2 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.14.1 lib/decidim/core/test/shared_examples/reports_examples.rb
decidim-core-0.13.1 lib/decidim/core/test/shared_examples/reports_examples.rb