diff options
Diffstat (limited to 'spec/lib/api/entities')
-rw-r--r-- | spec/lib/api/entities/ci/job_request/image_spec.rb | 16 | ||||
-rw-r--r-- | spec/lib/api/entities/personal_access_token_with_details_spec.rb | 29 | ||||
-rw-r--r-- | spec/lib/api/entities/wiki_page_spec.rb | 17 |
3 files changed, 61 insertions, 1 deletions
diff --git a/spec/lib/api/entities/ci/job_request/image_spec.rb b/spec/lib/api/entities/ci/job_request/image_spec.rb index 55aade03129..3ab14ffc3ae 100644 --- a/spec/lib/api/entities/ci/job_request/image_spec.rb +++ b/spec/lib/api/entities/ci/job_request/image_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' RSpec.describe API::Entities::Ci::JobRequest::Image do let(:ports) { [{ number: 80, protocol: 'http', name: 'name' }]} - let(:image) { double(name: 'image_name', entrypoint: ['foo'], ports: ports)} + let(:image) { double(name: 'image_name', entrypoint: ['foo'], ports: ports, pull_policy: ['if-not-present']) } let(:entity) { described_class.new(image) } subject { entity.as_json } @@ -28,4 +28,18 @@ RSpec.describe API::Entities::Ci::JobRequest::Image do expect(subject[:ports]).to be_nil end end + + it 'returns the pull policy' do + expect(subject[:pull_policy]).to eq(['if-not-present']) + end + + context 'when the FF ci_docker_image_pull_policy is disabled' do + before do + stub_feature_flags(ci_docker_image_pull_policy: false) + end + + it 'does not return the pull policy' do + expect(subject).not_to have_key(:pull_policy) + end + end end diff --git a/spec/lib/api/entities/personal_access_token_with_details_spec.rb b/spec/lib/api/entities/personal_access_token_with_details_spec.rb new file mode 100644 index 00000000000..a53d6febba1 --- /dev/null +++ b/spec/lib/api/entities/personal_access_token_with_details_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe API::Entities::PersonalAccessTokenWithDetails do + describe '#as_json' do + let_it_be(:user) { create(:user) } + let_it_be(:token) { create(:personal_access_token, user: user, expires_at: nil) } + + let(:entity) { described_class.new(token) } + + it 'returns token data' do + expect(entity.as_json).to eq({ + id: token.id, + name: token.name, + revoked: false, + created_at: token.created_at, + scopes: ['api'], + user_id: user.id, + last_used_at: nil, + active: true, + expires_at: nil, + expired: false, + expires_soon: false, + revoke_path: Gitlab::Routing.url_helpers.revoke_profile_personal_access_token_path(token) + }) + end + end +end diff --git a/spec/lib/api/entities/wiki_page_spec.rb b/spec/lib/api/entities/wiki_page_spec.rb index 238c8233a14..c75bba12484 100644 --- a/spec/lib/api/entities/wiki_page_spec.rb +++ b/spec/lib/api/entities/wiki_page_spec.rb @@ -43,6 +43,23 @@ RSpec.describe API::Entities::WikiPage do expect(subject[:content]).to eq("<div>
<p><strong>Test</strong> <em>content</em></p>
</div>") end end + + context 'when content contains a reference' do + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:issue) { create(:issue, project: project) } + let(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'page_with_ref', content: issue.to_reference) } + let(:expected_content) { %r{<a href=".*#{issue.iid}".*>#{issue.to_reference}</a>} } + + before do + params[:current_user] = user + project.add_developer(user) + end + + it 'expands the reference in the content' do + expect(subject[:content]).to match(expected_content) + end + end end context 'when it is false' do |