debian-mirror-gitlab/spec/controllers/projects/cycle_analytics_controller_spec.rb

64 lines
1.5 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
describe Projects::CycleAnalyticsController do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
sign_in(user)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2017-08-17 22:00:37 +05:30
end
2019-10-12 21:52:04 +05:30
context "counting page views for 'show'" do
it 'increases the counter' do
expect(Gitlab::UsageDataCounters::CycleAnalyticsCounter).to receive(:count).with(:views)
get(:show,
params: {
namespace_id: project.namespace,
project_id: project
})
2019-12-04 20:38:33 +05:30
expect(response).to be_successful
2019-10-12 21:52:04 +05:30
end
end
2017-08-17 22:00:37 +05:30
describe 'cycle analytics not set up flag' do
context 'with no data' do
it 'is true' do
get(:show,
2019-02-15 15:39:39 +05:30
params: {
namespace_id: project.namespace,
project_id: project
})
2017-08-17 22:00:37 +05:30
2019-12-04 20:38:33 +05:30
expect(response).to be_successful
2017-08-17 22:00:37 +05:30
expect(assigns(:cycle_analytics_no_data)).to eq(true)
end
end
context 'with data' do
before do
issue = create(:issue, project: project, created_at: 4.days.ago)
milestone = create(:milestone, project: project, created_at: 5.days.ago)
issue.update(milestone: milestone)
2018-03-27 19:54:05 +05:30
create_merge_request_closing_issue(user, project, issue)
2017-08-17 22:00:37 +05:30
end
it 'is false' do
get(:show,
2019-02-15 15:39:39 +05:30
params: {
namespace_id: project.namespace,
project_id: project
})
2017-08-17 22:00:37 +05:30
2019-12-04 20:38:33 +05:30
expect(response).to be_successful
2017-08-17 22:00:37 +05:30
expect(assigns(:cycle_analytics_no_data)).to eq(false)
end
end
end
end