Commit 169dc4ce authored by Rémy Coutable's avatar Rémy Coutable

Fix brittle specs

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 5f7cb263
FactoryGirl.define do
factory :issue do
title
title { generate(:title) }
author
project factory: :empty_project
......
FactoryGirl.define do
factory :merge_request do
title
title { generate(:title) }
author
association :source_project, :repository, factory: :project
target_project { source_project }
......
......@@ -3,6 +3,8 @@ FactoryGirl.define do
sequence(:name) { |n| "John Doe#{n}" }
sequence(:email) { |n| "user#{n}@example.org" }
sequence(:email_alias) { |n| "user.alias#{n}@example.org" }
sequence(:title) { |n| "My title #{n}" }
sequence(:filename) { |n| "filename-#{n}.rb" }
sequence(:url) { |n| "http://example#{n}.org" }
sequence(:label) { |n| "label#{n}" }
sequence(:branch) { |n| "my-branch-#{n}" }
......
FactoryGirl.define do
sequence(:title, aliases: [:content]) { |n| "My snippet #{n}" }
sequence(:file_name) { |n| "snippet-#{n}.rb" }
factory :snippet do
author
title
content
file_name
title { generate(:title) }
content { generate(:title) }
file_name { generate(:filename) }
trait :public do
visibility_level Snippet::PUBLIC
......
require 'spec_helper'
describe 'Admin browse spam logs' do
let!(:spam_log) { create(:spam_log) }
let!(:spam_log) { create(:spam_log, description: 'abcde ' * 20) }
before do
login_as :admin
......
......@@ -51,7 +51,7 @@ describe 'issuable list', feature: true do
if issuable_type == :issue
create(:issue, project: project, author: user)
else
create(:merge_request, source_project: project, source_branch: "#{n}-feature")
create(:merge_request, source_project: project, source_branch: generate(:branch))
end
2.times do
......@@ -66,7 +66,7 @@ describe 'issuable list', feature: true do
issue = Issue.reorder(:iid).first
merge_request = create(:merge_request,
source_project: project,
source_branch: 'my-bug-fix')
source_branch: generate(:branch))
MergeRequestsClosingIssues.create!(issue: issue, merge_request: merge_request)
end
......
module CycleAnalyticsHelpers
def create_commit_referencing_issue(issue, branch_name: nil)
project.repository.add_branch(user, branch_name || generate(:branch), 'master')
def create_commit_referencing_issue(issue, branch_name: generate(:branch))
project.repository.add_branch(user, branch_name, 'master')
create_commit("Commit for ##{issue.iid}", issue.project, user, branch_name)
end
......
......@@ -63,9 +63,9 @@ module FilterSpecHelper
#
# Returns a String
def invalidate_reference(reference)
if reference =~ /\A(.+)?.\d+\z/
if reference =~ /\A(.+)?[^\d]\d+\z/
# Integer-based reference with optional project prefix
reference.gsub(/\d+\z/) { |i| i.to_i + 1 }
reference.gsub(/\d+\z/) { |i| i.to_i + 10_000 }
elsif reference =~ /\A(.+@)?(\h{7,40}\z)/
# SHA-based reference with optional prefix
reference.gsub(/\h{7,40}\z/) { |v| v.reverse }
......
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