debian-mirror-gitlab/spec/services/applications/create_service_spec.rb

30 lines
825 B
Ruby
Raw Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
require "spec_helper"
2018-03-17 18:26:18 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe ::Applications::CreateService do
2018-12-13 13:39:08 +05:30
include TestRequestHelpers
2018-03-17 18:26:18 +05:30
let(:user) { create(:user) }
subject { described_class.new(user, params) }
2020-09-03 11:15:55 +05:30
context 'when scopes are present' do
let(:params) { attributes_for(:application, scopes: ['read_user']) }
it { expect { subject.execute(test_request) }.to change { Doorkeeper::Application.count }.by(1) }
end
context 'when scopes are missing' do
let(:params) { attributes_for(:application) }
it { expect { subject.execute(test_request) }.not_to change { Doorkeeper::Application.count } }
it 'includes blank scopes error message' do
application = subject.execute(test_request)
expect(application.errors.full_messages).to include "Scopes can't be blank"
end
end
2018-03-17 18:26:18 +05:30
end