2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe DashboardController do
|
2018-11-29 20:51:05 +05:30
|
|
|
context 'signed in' do
|
2022-11-25 23:54:43 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
before_all do
|
2018-11-29 20:51:05 +05:30
|
|
|
project.add_maintainer(user)
|
2022-11-25 23:54:43 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2018-11-29 20:51:05 +05:30
|
|
|
sign_in(user)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-29 20:51:05 +05:30
|
|
|
describe 'GET issues' do
|
2022-05-07 20:08:51 +05:30
|
|
|
context 'when issues_full_text_search is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(issues_full_text_search: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'issuables list meta-data', :issue, :issues
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when issues_full_text_search is enabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(issues_full_text_search: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'issuables list meta-data', :issue, :issues
|
|
|
|
end
|
|
|
|
|
2018-11-29 20:51:05 +05:30
|
|
|
it_behaves_like 'issuables requiring filter', :issues
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
it 'includes tasks in issue list' do
|
|
|
|
task = create(:work_item, :task, project: project, author: user)
|
|
|
|
|
|
|
|
get :issues, params: { author_id: user.id }
|
|
|
|
|
|
|
|
expect(assigns[:issues].map(&:id)).to include(task.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when work_items is disabled' do
|
|
|
|
before do
|
|
|
|
stub_feature_flags(work_items: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not include tasks in issue list' do
|
|
|
|
task = create(:work_item, :task, project: project, author: user)
|
|
|
|
|
|
|
|
get :issues, params: { author_id: user.id }
|
|
|
|
|
|
|
|
expect(assigns[:issues].map(&:id)).not_to include(task.id)
|
|
|
|
end
|
|
|
|
end
|
2018-11-29 20:51:05 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-29 20:51:05 +05:30
|
|
|
describe 'GET merge requests' do
|
|
|
|
it_behaves_like 'issuables list meta-data', :merge_request, :merge_requests
|
|
|
|
it_behaves_like 'issuables requiring filter', :merge_requests
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-11-29 20:51:05 +05:30
|
|
|
|
2020-02-01 01:16:34 +05:30
|
|
|
describe "GET activity as JSON" do
|
2020-07-28 23:09:34 +05:30
|
|
|
include DesignManagementTestHelpers
|
2020-02-01 01:16:34 +05:30
|
|
|
render_views
|
|
|
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public, issues_access_level: ProjectFeature::PRIVATE) }
|
2020-07-28 23:09:34 +05:30
|
|
|
let(:other_project) { create(:project, :public) }
|
2020-02-01 01:16:34 +05:30
|
|
|
|
|
|
|
before do
|
2020-07-28 23:09:34 +05:30
|
|
|
enable_design_management
|
2020-02-01 01:16:34 +05:30
|
|
|
create(:event, :created, project: project, target: create(:issue))
|
2020-04-22 19:07:51 +05:30
|
|
|
create(:wiki_page_event, :created, project: project)
|
|
|
|
create(:wiki_page_event, :updated, project: project)
|
2020-07-28 23:09:34 +05:30
|
|
|
create(:design_event, project: project)
|
|
|
|
create(:design_event, author: user, project: other_project)
|
2020-02-01 01:16:34 +05:30
|
|
|
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
request.cookies[:event_filter] = 'all'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user has permission to see the event' do
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
2020-07-28 23:09:34 +05:30
|
|
|
other_project.add_developer(user)
|
2020-02-01 01:16:34 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns count' do
|
|
|
|
get :activity, params: { format: :json }
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
expect(json_response['count']).to eq(6)
|
2020-02-01 01:16:34 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when user has no permission to see the event' do
|
|
|
|
it 'filters out invisible event' do
|
|
|
|
get :activity, params: { format: :json }
|
|
|
|
|
|
|
|
expect(json_response['html']).to include(_('No activities found'))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'filters out invisible event when calculating the count' do
|
|
|
|
get :activity, params: { format: :json }
|
|
|
|
|
|
|
|
expect(json_response['count']).to eq(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
describe "#check_filters_presence!" do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
get :merge_requests, params: params
|
|
|
|
end
|
|
|
|
|
|
|
|
context "no filters" do
|
|
|
|
let(:params) { {} }
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
shared_examples_for 'no filters are set' do
|
|
|
|
it 'sets @no_filters_set to true' do
|
|
|
|
expect(assigns[:no_filters_set]).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'no filters are set'
|
|
|
|
|
|
|
|
context 'when key is present but value is not' do
|
|
|
|
let(:params) { { author_username: nil } }
|
|
|
|
|
|
|
|
it_behaves_like 'no filters are set'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when in param is set but no search' do
|
|
|
|
let(:params) { { in: 'title' } }
|
|
|
|
|
|
|
|
it_behaves_like 'no filters are set'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
shared_examples_for 'filters are set' do
|
2019-07-07 11:18:12 +05:30
|
|
|
it 'sets @no_filters_set to false' do
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(assigns[:no_filters_set]).to eq(false)
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "scalar filters" do
|
|
|
|
let(:params) { { author_id: user.id } }
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it_behaves_like 'filters are set'
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context "array filters" do
|
|
|
|
let(:params) { { label_name: ['bug'] } }
|
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
it_behaves_like 'filters are set'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'search' do
|
|
|
|
let(:params) { { search: 'test' } }
|
|
|
|
|
|
|
|
it_behaves_like 'filters are set'
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|