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