diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-10-31 14:54:49 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-10-31 14:54:49 +0300 |
commit | e829d5a08455e608ba5f054ffa65a2af0fe0393c (patch) | |
tree | 635b600e2fa432a21a70786d3c64fe847d57fec7 /spec/models/project_services | |
parent | a9446093b12a9dffef97541915e2b6872875ad3f (diff) | |
parent | c207122fd2b4439ff8303a1860c35de658d6bdfb (diff) |
Merge branch 'add-packagist-project-service' into 'master'
Add Packagist project service
See merge request gitlab-org/gitlab-ce!14493
Diffstat (limited to 'spec/models/project_services')
-rw-r--r-- | spec/models/project_services/packagist_service_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/models/project_services/packagist_service_spec.rb b/spec/models/project_services/packagist_service_spec.rb new file mode 100644 index 00000000000..6acee311700 --- /dev/null +++ b/spec/models/project_services/packagist_service_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe PackagistService do + describe "Associations" do + it { is_expected.to belong_to :project } + it { is_expected.to have_one :service_hook } + end + + let(:project) { create(:project) } + + let(:packagist_server) { 'https://packagist.example.com' } + let(:packagist_username) { 'theUser' } + let(:packagist_token) { 'verySecret' } + let(:packagist_hook_url) do + "#{packagist_server}/api/update-package?username=#{packagist_username}&apiToken=#{packagist_token}" + end + + let(:packagist_params) do + { + active: true, + project: project, + properties: { + username: packagist_username, + token: packagist_token, + server: packagist_server + } + } + end + + describe '#execute' do + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + let(:push_sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) } + let(:packagist_service) { described_class.create(packagist_params) } + + before do + stub_request(:post, packagist_hook_url) + end + + it 'calls Packagist API' do + packagist_service.execute(push_sample_data) + + expect(a_request(:post, packagist_hook_url)).to have_been_made.once + end + end +end |