diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/groups_spec.rb | 2 | ||||
-rw-r--r-- | spec/frontend/ci/jobs_page/components/jobs_table_empty_state_spec.js | 2 | ||||
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 33 | ||||
-rw-r--r-- | spec/initializers/hangouts_chat_http_override_spec.rb | 34 | ||||
-rw-r--r-- | spec/models/integrations/hangouts_chat_spec.rb | 2 | ||||
-rw-r--r-- | spec/views/groups/show.html.haml_spec.rb | 15 |
6 files changed, 49 insertions, 39 deletions
diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index 7af58bf460c..bcbfdf487ac 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -544,7 +544,7 @@ RSpec.describe 'Group', feature_category: :groups_and_projects do describe 'group README', :js do context 'with gitlab-profile project and README.md' do let_it_be(:group) { create(:group) } - let_it_be(:project) { create(:project, :readme, namespace: group) } + let_it_be(:project) { create(:project, :public, :readme, namespace: group) } it 'renders README block on group page' do visit group_path(group) diff --git a/spec/frontend/ci/jobs_page/components/jobs_table_empty_state_spec.js b/spec/frontend/ci/jobs_page/components/jobs_table_empty_state_spec.js index f4893c4077f..0f85c4590ec 100644 --- a/spec/frontend/ci/jobs_page/components/jobs_table_empty_state_spec.js +++ b/spec/frontend/ci/jobs_page/components/jobs_table_empty_state_spec.js @@ -6,7 +6,7 @@ describe('Jobs table empty state', () => { let wrapper; const pipelineEditorPath = '/root/project/-/ci/editor'; - const emptyStateSvgPath = 'assets/jobs-empty-state.svg'; + const emptyStateSvgPath = 'illustrations/empty-state/empty-pipeline-md.svg'; const findEmptyState = () => wrapper.findComponent(GlEmptyState); diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 2cdb934eb0a..dce64280988 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -524,6 +524,39 @@ RSpec.describe GroupsHelper do end end + describe '#show_group_readme?' do + let_it_be_with_refind(:group) { create(:group, :public) } + let_it_be(:current_user) { nil } + + before do + allow(helper).to receive(:current_user).and_return(current_user) + end + + context 'when project is public' do + let_it_be(:project) { create(:project, :public, :readme, group: group, path: 'gitlab-profile') } + + it { expect(helper.show_group_readme?(group)).to be(true) } + end + + context 'when project is private' do + let_it_be(:project) { create(:project, :private, :readme, group: group, path: 'gitlab-profile') } + + context 'when user can see the project' do + let_it_be(:current_user) { create(:user) } + + before do + project.add_developer(current_user) + end + + it { expect(helper.show_group_readme?(group)).to be(true) } + end + + it 'when user can not see the project' do + expect(helper.show_group_readme?(group)).to be(false) + end + end + end + describe "#enabled_git_access_protocol_options_for_group" do subject { helper.enabled_git_access_protocol_options_for_group } diff --git a/spec/initializers/hangouts_chat_http_override_spec.rb b/spec/initializers/hangouts_chat_http_override_spec.rb deleted file mode 100644 index 42236c8c853..00000000000 --- a/spec/initializers/hangouts_chat_http_override_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'HangoutsChat::Sender Gitlab::HTTP override' do - describe 'HangoutsChat::Sender::HTTP#post' do - it 'calls Gitlab::HTTP.post with default protection settings' do - webhook_url = 'https://example.gitlab.com' - payload = { key: 'value' } - http = HangoutsChat::Sender::HTTP.new(webhook_url) - mock_response = double(response: 'the response') - - expect(Gitlab::HTTP).to receive(:post) - .with( - URI.parse(webhook_url), - body: payload.to_json, - headers: { 'Content-Type' => 'application/json' }, - parse: nil - ) - .and_return(mock_response) - - expect(http.post(payload)).to eq(mock_response.response) - end - - it_behaves_like 'a request using Gitlab::UrlBlocker' do - let(:http_method) { :post } - let(:url_blocked_error_class) { Gitlab::HTTP::BlockedUrlError } - - def make_request(uri) - HangoutsChat::Sender::HTTP.new(uri).post({}) - end - end - end -end diff --git a/spec/models/integrations/hangouts_chat_spec.rb b/spec/models/integrations/hangouts_chat_spec.rb index bcb80768ffb..a1ecfd436c2 100644 --- a/spec/models/integrations/hangouts_chat_spec.rb +++ b/spec/models/integrations/hangouts_chat_spec.rb @@ -4,7 +4,7 @@ require "spec_helper" RSpec.describe Integrations::HangoutsChat, feature_category: :integrations do it_behaves_like "chat integration", "Hangouts Chat" do - let(:client) { HangoutsChat::Sender } + let(:client) { Gitlab::HTTP } let(:client_arguments) { webhook_url } let(:payload) do { diff --git a/spec/views/groups/show.html.haml_spec.rb b/spec/views/groups/show.html.haml_spec.rb index c4142f4a245..e0ee60e9f91 100644 --- a/spec/views/groups/show.html.haml_spec.rb +++ b/spec/views/groups/show.html.haml_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'groups/show', feature_category: :groups_and_projects do describe 'group README' do let_it_be(:group) { build_stubbed(:group) } - let_it_be(:readme_project) { build_stubbed(:project, :readme) } + let_it_be(:readme_project) { build_stubbed(:project, :public, :readme) } before do assign(:group, group) @@ -14,6 +14,7 @@ RSpec.describe 'groups/show', feature_category: :groups_and_projects do context 'with readme project' do before do allow(group).to receive(:group_readme).and_return(readme_project) + allow(group).to receive(:readme_project).and_return(readme_project) end it 'renders #js-group-readme' do @@ -21,11 +22,21 @@ RSpec.describe 'groups/show', feature_category: :groups_and_projects do expect(rendered).to have_selector('#js-group-readme') end + + context 'with private readme project' do + let_it_be(:readme_project) { build_stubbed(:project, :private, :readme) } + + it 'does not render #js-group-readme' do + render + + expect(rendered).not_to have_selector('#js-group-readme') + end + end end context 'without readme project' do before do - allow(group).to receive(:group_readme).and_return(nil) + allow(group).to receive(:readme_project).and_return(nil) end it 'does not render #js-group-readme' do |