2019-04-15 10:17:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-23 20:40:25 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe DashboardController do
|
2018-11-28 19:06:02 +00:00
|
|
|
context 'signed in' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project) }
|
2017-01-23 20:40:25 +00:00
|
|
|
|
2018-11-28 19:06:02 +00:00
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
2017-01-23 20:40:25 +00:00
|
|
|
|
2018-11-28 19:06:02 +00:00
|
|
|
describe 'GET issues' do
|
|
|
|
it_behaves_like 'issuables list meta-data', :issue, :issues
|
|
|
|
it_behaves_like 'issuables requiring filter', :issues
|
|
|
|
end
|
2017-01-23 20:40:25 +00:00
|
|
|
|
2018-11-28 19:06:02 +00:00
|
|
|
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-01-23 20:40:25 +00:00
|
|
|
end
|
2018-11-28 19:06:02 +00:00
|
|
|
|
2020-01-30 21:08:47 +00:00
|
|
|
describe "GET activity as JSON" do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public, issues_access_level: ProjectFeature::PRIVATE) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
create(:event, :created, project: project, target: create(:issue))
|
2020-03-25 12:08:19 +00:00
|
|
|
create(:wiki_page_event, :created, project: project)
|
|
|
|
create(:wiki_page_event, :updated, project: project)
|
2020-01-30 21:08:47 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns count' do
|
|
|
|
get :activity, params: { format: :json }
|
|
|
|
|
2020-03-25 12:08:19 +00:00
|
|
|
expect(json_response['count']).to eq(3)
|
2020-01-30 21:08:47 +00:00
|
|
|
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
|
|
|
|
|
2018-11-28 19:06:02 +00:00
|
|
|
it_behaves_like 'authenticates sessionless user', :issues, :atom, author_id: User.first
|
|
|
|
it_behaves_like 'authenticates sessionless user', :issues_calendar, :ics
|
2019-04-04 14:54:25 +00:00
|
|
|
|
|
|
|
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) { {} }
|
|
|
|
|
|
|
|
it 'sets @no_filters_set to false' do
|
|
|
|
expect(assigns[:no_filters_set]).to eq(true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "scalar filters" do
|
|
|
|
let(:params) { { author_id: user.id } }
|
|
|
|
|
|
|
|
it 'sets @no_filters_set to false' do
|
|
|
|
expect(assigns[:no_filters_set]).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "array filters" do
|
|
|
|
let(:params) { { label_name: ['bug'] } }
|
|
|
|
|
|
|
|
it 'sets @no_filters_set to false' do
|
|
|
|
expect(assigns[:no_filters_set]).to eq(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-01-23 20:40:25 +00:00
|
|
|
end
|