Commit 1dde18f3 authored by Małgorzata Ksionek's avatar Małgorzata Ksionek

Add code review remarks

Make specs more readable
parent 72cddf5a
......@@ -2,7 +2,7 @@
module CycleAnalytics
class GroupLevel
include BaseMethods
include LevelBase
attr_reader :options
def initialize(options:)
......
# frozen_string_literal: true
module CycleAnalytics
module BaseMethods
module LevelBase
STAGES = %i[issue plan code test review staging production].freeze
def all_medians_by_stage
......
......@@ -2,7 +2,7 @@
module CycleAnalytics
class ProjectLevel
include BaseMethods
include LevelBase
attr_reader :project, :options
def initialize(project, options:)
......
......@@ -23,7 +23,7 @@ module Gitlab
end
def get
::CycleAnalytics::BaseMethods::STAGES.each do |stage|
::CycleAnalytics::LevelBase::STAGES.each do |stage|
@stage_permission_hash[stage] = authorized_stage?(stage)
end
......
......@@ -34,11 +34,11 @@ describe Gitlab::CycleAnalytics::CodeStage do
end
describe '#events' do
it 'exposes merge requests that closes issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:title] }).to contain_exactly(mr_1.title, mr_2.title)
it 'exposes merge requests that closes issues' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:title] }).to contain_exactly(mr_1.title, mr_2.title)
end
end
......@@ -74,11 +74,11 @@ describe Gitlab::CycleAnalytics::CodeStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:title] }).to contain_exactly(mr_2_1.title, mr_2_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:title] }).to contain_exactly(mr_2_1.title, mr_2_2.title)
end
end
......@@ -101,18 +101,16 @@ describe Gitlab::CycleAnalytics::CodeStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(4)
expect(result.map { |event| event[:title] }).to contain_exactly(mr_2_1.title, mr_2_2.title, mr_3_1.title, mr_3_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(4)
expect(subject.map { |event| event[:title] }).to contain_exactly(mr_2_1.title, mr_2_2.title, mr_3_1.title, mr_3_2.title)
end
it 'exposes merge requests that close issues with full path for subgroup' do
result = stage.events
expect(result.count).to eq(4)
expect(result.find { |event| event[:title] == mr_3_1.title }[:url]).to include("#{subgroup.full_path}")
expect(subject.count).to eq(4)
expect(subject.find { |event| event[:title] == mr_3_1.title }[:url]).to include("#{subgroup.full_path}")
end
end
end
......
......@@ -7,6 +7,7 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
let(:project_2) { create(:project, :repository, namespace: group) }
let(:from) { 1.day.ago }
let(:user) { create(:user, :admin) }
subject { described_class.new(group, from: Time.now, current_user: user).data }
describe "#new_issues" do
......
......@@ -63,11 +63,11 @@ describe Gitlab::CycleAnalytics::IssueStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title)
end
end
......@@ -85,18 +85,16 @@ describe Gitlab::CycleAnalytics::IssueStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(4)
expect(result.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title, issue_3_1.title, issue_3_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(4)
expect(subject.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title, issue_3_1.title, issue_3_2.title)
end
it 'exposes merge requests that close issues with full path for subgroup' do
result = stage.events
expect(result.count).to eq(4)
expect(result.find { |event| event[:title] == issue_3_1.title }[:url]).to include("#{subgroup.full_path}")
expect(subject.count).to eq(4)
expect(subject.find { |event| event[:title] == issue_3_1.title }[:url]).to include("#{subgroup.full_path}")
end
end
end
......
......@@ -29,11 +29,11 @@ describe Gitlab::CycleAnalytics::PlanStage do
end
describe '#events' do
it 'exposes issues with metrics' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:title] }).to contain_exactly(issue_1.title, issue_2.title)
it 'exposes issues with metrics' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:title] }).to contain_exactly(issue_1.title, issue_2.title)
end
end
......@@ -65,11 +65,11 @@ describe Gitlab::CycleAnalytics::PlanStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title)
end
end
......@@ -88,18 +88,16 @@ describe Gitlab::CycleAnalytics::PlanStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(4)
expect(result.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title, issue_3_1.title, issue_3_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(4)
expect(subject.map { |event| event[:title] }).to contain_exactly(issue_2_1.title, issue_2_2.title, issue_3_1.title, issue_3_2.title)
end
it 'exposes merge requests that close issues with full path for subgroup' do
result = stage.events
expect(result.count).to eq(4)
expect(result.find { |event| event[:title] == issue_3_1.title }[:url]).to include("#{subgroup.full_path}")
expect(subject.count).to eq(4)
expect(subject.find { |event| event[:title] == issue_3_1.title }[:url]).to include("#{subgroup.full_path}")
end
end
end
......
......@@ -35,13 +35,14 @@ describe Gitlab::CycleAnalytics::ReviewStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:title] }).to contain_exactly(mr_1.title, mr_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:title] }).to contain_exactly(mr_1.title, mr_2.title)
end
end
context 'when group is given' do
let(:user) { create(:user) }
let(:group) { create(:group) }
......@@ -77,11 +78,11 @@ describe Gitlab::CycleAnalytics::ReviewStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:title] }).to contain_exactly(mr_2_1.title, mr_2_2.title)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:title] }).to contain_exactly(mr_2_1.title, mr_2_2.title)
end
end
end
......
......@@ -39,11 +39,11 @@ describe Gitlab::CycleAnalytics::StagingStage do
end
describe '#events' do
it 'exposes builds connected to merge request' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:name] }).to contain_exactly(build_1.name, build_2.name)
it 'exposes builds connected to merge request' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:name] }).to contain_exactly(build_1.name, build_2.name)
end
end
......@@ -84,11 +84,11 @@ describe Gitlab::CycleAnalytics::StagingStage do
end
describe '#events' do
it 'exposes merge requests that close issues' do
result = stage.events
subject { stage.events }
expect(result.count).to eq(2)
expect(result.map { |event| event[:name] }).to contain_exactly(build_1.name, build_2.name)
it 'exposes merge requests that close issues' do
expect(subject.count).to eq(2)
expect(subject.map { |event| event[:name] }).to contain_exactly(build_1.name, build_2.name)
end
end
end
......
......@@ -34,7 +34,7 @@ describe Gitlab::CycleAnalytics::UsageData do
expect(result).to have_key(:avg_cycle_analytics)
CycleAnalytics::BaseMethods::STAGES.each do |stage|
CycleAnalytics::LevelBase::STAGES.each do |stage|
expect(result[:avg_cycle_analytics]).to have_key(stage)
stage_values = result[:avg_cycle_analytics][stage]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment