diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-06-13 10:25:25 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-07-24 08:10:14 +0200 |
commit | 2fa22a07296223c1239bfab94654487cca222097 (patch) | |
tree | cf930855ad24ad2770a832d530e5a5ae36719825 /spec | |
parent | b92d5135d8522e1370636799d74b51f9a37d0b2f (diff) | |
download | gitlab-ce-2fa22a07296223c1239bfab94654487cca222097.tar.gz |
Associate Issues tab only with internal issues tracker
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/issues_controller_spec.rb | 59 | ||||
-rw-r--r-- | spec/features/projects/features_visibility_spec.rb | 19 | ||||
-rw-r--r-- | spec/policies/project_policy_spec.rb | 24 |
3 files changed, 79 insertions, 23 deletions
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 18d0be3c103..e56f5d11daf 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -7,16 +7,30 @@ describe Projects::IssuesController do describe "GET #index" do context 'external issue tracker' do - let!(:service) do - create(:custom_issue_tracker_service, project: project, title: 'Custom Issue Tracker', project_url: 'http://test.com') + before do + sign_in(user) + project.add_developer(user) + create(:jira_service, project: project) end - it 'redirects to the external issue tracker' do - controller.instance_variable_set(:@project, project) + context 'when GitLab issues disabled' do + it 'returns 404 status' do + project.issues_enabled = false + project.save! - get :index, namespace_id: project.namespace, project_id: project + get :index, namespace_id: project.namespace, project_id: project + + expect(response).to have_http_status(404) + end + end + + context 'when GitLab issues enabled' do + it 'renders the "index" template' do + get :index, namespace_id: project.namespace, project_id: project - expect(response).to redirect_to(service.issue_tracker_path) + expect(response).to have_http_status(200) + expect(response).to render_template(:index) + end end end @@ -42,15 +56,7 @@ describe Projects::IssuesController do it "returns 404 when issues are disabled" do project.issues_enabled = false - project.save - - get :index, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(404) - end - - it "returns 404 when external issue tracker is enabled" do - controller.instance_variable_set(:@project, project) - allow(project).to receive(:default_issues_tracker?).and_return(false) + project.save! get :index, namespace_id: project.namespace, project_id: project expect(response).to have_http_status(404) @@ -148,14 +154,29 @@ describe Projects::IssuesController do before do sign_in(user) project.team << [user, :developer] + + external = double + allow(project).to receive(:external_issue_tracker).and_return(external) end - it 'redirects to the external issue tracker' do - controller.instance_variable_set(:@project, project) + context 'when GitLab issues disabled' do + it 'returns 404 status' do + project.issues_enabled = false + project.save! - get :new, namespace_id: project.namespace, project_id: project + get :new, namespace_id: project.namespace, project_id: project - expect(response).to redirect_to('http://test.com') + expect(response).to have_http_status(404) + end + end + + context 'when GitLab issues enabled' do + it 'renders the "new" template' do + get :new, namespace_id: project.namespace, project_id: project + + expect(response).to have_http_status(200) + expect(response).to render_template(:new) + end end end end diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 827e02a58d0..2091c7b79d3 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -39,14 +39,25 @@ describe 'Edit Project Settings', feature: true do end end - context "When external issue tracker is enabled" do - it "does not hide issues tab" do - project.project_feature.update(issues_access_level: ProjectFeature::DISABLED) + context 'When external issue tracker is enabled and issues enabled on project settings' do + it 'does not hide issues tab' do allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(JiraService.new) visit project_path(project) - expect(page).to have_selector(".shortcuts-issues") + expect(page).to have_selector('.shortcuts-issues') + end + end + + context 'When external issue tracker is enabled and issues disabled on project settings' do + it 'hides issues tab' do + project.issues_enabled = false + project.save! + allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(JiraService.new) + + visit namespace_project_path(project.namespace, project) + + expect(page).not_to have_selector('.shortcuts-issues') end end diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb index ca435dd0218..4ed788af811 100644 --- a/spec/policies/project_policy_spec.rb +++ b/spec/policies/project_policy_spec.rb @@ -103,6 +103,30 @@ describe ProjectPolicy, models: true do end end + context 'issues feature' do + subject { described_class.new(owner, project) } + + context 'when the feature is disabled' do + it 'does not include the issues permissions' do + project.issues_enabled = false + project.save! + + expect_disallowed :read_issue, :create_issue, :update_issue, :admin_issue + end + end + + context 'when the feature is disabled and external tracker configured' do + it 'does not include the issues permissions' do + create(:jira_service, project: project) + + project.issues_enabled = false + project.save! + + expect_disallowed :read_issue, :create_issue, :update_issue, :admin_issue + end + end + end + context 'abilities for non-public projects' do let(:project) { create(:empty_project, namespace: owner.namespace) } |