918e589c2b
- Don't use `TableReferences` - using `.arel_table` is shorter! - Move some database-related code to `Gitlab::Database` - Remove the `MergeRequest#issues_closed` and `Issue#closed_by_merge_requests` associations. They were either shadowing or were too similar to existing methods. They are not being used anywhere, so it's better to remove them to reduce confusion. - Use Rails 3-style validations - Index for `MergeRequest::Metrics#first_deployed_to_production_at` - Only include `CycleAnalyticsHelpers::TestGeneration` for specs that need it. - Other minor refactorings.
42 lines
1.5 KiB
Ruby
42 lines
1.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe 'CycleAnalytics#code', feature: true do
|
|
extend CycleAnalyticsHelpers::TestGeneration
|
|
|
|
let(:project) { create(:project) }
|
|
let(:from_date) { 10.days.ago }
|
|
let(:user) { create(:user, :admin) }
|
|
subject { CycleAnalytics.new(project, from: from_date) }
|
|
|
|
generate_cycle_analytics_spec(
|
|
phase: :code,
|
|
data_fn: -> (context) { { issue: context.create(:issue, project: context.project) } },
|
|
start_time_conditions: [["issue mentioned in a commit",
|
|
-> (context, data) do
|
|
context.create_commit_referencing_issue(data[:issue])
|
|
end]],
|
|
end_time_conditions: [["merge request that closes issue is created",
|
|
-> (context, data) do
|
|
context.create_merge_request_closing_issue(data[:issue])
|
|
end]],
|
|
post_fn: -> (context, data) do
|
|
context.merge_merge_requests_closing_issue(data[:issue])
|
|
context.deploy_master
|
|
end)
|
|
|
|
context "when a regular merge request (that doesn't close the issue) is created" do
|
|
it "returns nil" do
|
|
5.times do
|
|
issue = create(:issue, project: project)
|
|
|
|
create_commit_referencing_issue(issue)
|
|
create_merge_request_closing_issue(issue, message: "Closes nothing")
|
|
|
|
merge_merge_requests_closing_issue(issue)
|
|
deploy_master
|
|
end
|
|
|
|
expect(subject.code).to be_nil
|
|
end
|
|
end
|
|
end
|