Sha256: fb0f9281f8d83f3298fd3efeec72d98a039ff1bcba83534302ffd553b35094c5

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

module MnoEnterprise::TestingSupport::SharedExamples::JpiV1Admin
  shared_examples "a jpi v1 admin action" do
    context "without a signed in user" do
      before { sign_out('user') }

      it "prevents access" do
        expect(subject).to_not be_successful
        expect(subject.code).to eq('401')
      end
    end

    context "with a non admin signed in user" do
      let(:user) { FactoryGirl.build(:user) }
      before do
        api_stub_for(get: "/users/#{user.id}", response: from_api(user))
        sign_in user
      end

      it "prevents access" do
        expect(subject).to_not be_successful
        expect(subject.code).to eq('401')
      end
    end

    context "with a signed in admin" do
      let(:user) { FactoryGirl.build(:user, :admin, :with_organizations) }
      before do
        api_stub_for(get: "/users/#{user.id}", response: from_api(user))
        sign_in user
      end

      it "authorizes access" do
        sign_in user
        expect(subject).to be_successful
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mno-enterprise-core-3.4.0 lib/mno_enterprise/testing_support/shared_examples/jpi_v1_admin.rb
mno-enterprise-core-3.3.3 lib/mno_enterprise/testing_support/shared_examples/jpi_v1_admin.rb
mno-enterprise-core-3.3.2 lib/mno_enterprise/testing_support/shared_examples/jpi_v1_admin.rb
mno-enterprise-core-3.2.1 lib/mno_enterprise/testing_support/shared_examples/jpi_v1_admin.rb
mno-enterprise-core-3.3.1 lib/mno_enterprise/testing_support/shared_examples/jpi_v1_admin.rb
mno-enterprise-core-3.3.0 lib/mno_enterprise/testing_support/shared_examples/jpi_v1_admin.rb
mno-enterprise-core-3.2.0 lib/mno_enterprise/testing_support/shared_examples/jpi_v1_admin.rb