Sha256: 7fbccae9a2ebb840caad4adada5a0a8621b070da1e43aabbe3a35bdfa371a6f5

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

# frozen_string_literal: true
require "spec_helper"

describe "Organization scopes", type: :feature do
  include ActionView::Helpers::SanitizeHelper

  let(:admin) { create :user, :admin, :confirmed }
  let(:organization) { admin.organization }

  before do
    switch_to_host(organization.host)
  end

  describe "Managing scopes" do
    before do
      login_as admin, scope: :user
      visit decidim_admin.root_path
      click_link "Settings"
      click_link "Scopes"
    end

    it "can create new scopes" do
      click_link "Add"

      within ".new_scope" do
        fill_in :scope_name, with: "My nice district"

        find("*[type=submit]").click
      end

      within ".callout-wrapper" do
        expect(page).to have_content("successfully")
      end

      within "table" do
        expect(page).to have_content("My nice district")
      end
    end

    context "with existing scopes" do
      let!(:scope) { create(:scope, organization: organization) }

      before do
        visit current_path
      end

      it "can edit them" do
        within find("tr", text: scope.name) do
          page.find("a.action-icon.action-icon--edit").click
        end

        within ".edit_scope" do
          fill_in :scope_name, with: "Another district"
          find("*[type=submit]").click
        end

        within ".callout-wrapper" do
          expect(page).to have_content("successfully")
        end

        within "table" do
          expect(page).to have_content("Another district")
        end
      end

      it "can destroy them" do
        within find("tr", text: scope.name) do
          page.find("a.action-icon.action-icon--remove").click
        end

        within ".callout-wrapper" do
          expect(page).to have_content("successfully")
        end

        within "table" do
          expect(page).not_to have_content(scope.name)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
decidim-0.1.0 decidim-admin/spec/features/admin_manages_organization_scopes_spec.rb