2018-10-10 04:45:49 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-02 04:12:20 -04:00
|
|
|
require "spec_helper"
|
2017-10-24 02:38:06 -04:00
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe ::Applications::CreateService do
|
2018-10-10 04:45:49 -04:00
|
|
|
include TestRequestHelpers
|
|
|
|
|
2017-10-24 02:38:06 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
subject { described_class.new(user, params) }
|
|
|
|
|
2020-09-02 11:10:54 -04:00
|
|
|
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
|
2017-10-24 02:38:06 -04:00
|
|
|
end
|