Sha256: 274523937d94ec5d91352057af7685f6937a69e0fd1e6d752bfa1a8d7a23bd84
Contents?: true
Size: 1.25 KB
Versions: 23
Compression:
Stored size: 1.25 KB
Contents
module MnoEnterprise::TestingSupport::JpiV1TestHelper # Expect 'user' to be assigned shared_examples "jpi v1 protected action" do context "with guest user" do it "prevents access" do sign_out user expect(subject).to_not be_successful expect(subject.code).to eq('401') end end context 'with signed in user' do it "authorizes access" do sign_in user expect(subject).to be_successful end end end # Expect 'user' to be assigned # Expect 'ability' to be assigned shared_examples "jpi v1 authorizable action" do context "with guest user" do it "prevents access" do sign_out user expect(subject).to_not be_successful expect(subject.code).to eq('401') end end context 'with unauthorized signed in user' do it "prevents access" do sign_in user allow(ability).to receive(:can?).with(any_args).and_return(false) expect(subject).to_not be_successful end end context 'with authorized signed in user' do it "authorizes access" do sign_in user allow(ability).to receive(:can?).with(any_args).and_return(true) expect(subject).to be_successful end end end end
Version data entries
23 entries across 23 versions & 1 rubygems