GitLab steht Mittwoch, den 08. Juli, zwischen 09:00 und 13:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

Commit 80fb38de authored by Vincent Bonmalais's avatar Vincent Bonmalais

Remove backward compatibility of factories.

parent d52f06f3
......@@ -32,7 +32,7 @@ class Dashboard < Spinach::FeatureSteps
end
Given 'user with name "John Doe" joined project "Shop"' do
user = create :user, {name: "John Doe"}
user = create(:user, {name: "John Doe"})
project = Project.find_by_name "Shop"
Event.create(
project: project,
......@@ -65,9 +65,9 @@ class Dashboard < Spinach::FeatureSteps
end
And 'I have group with projects' do
@group = create :group
@project = create :project, group: @group
@event = create :closed_issue_event, project: @project
@group = create(:group)
@project = create(:project, group: @group)
@event = create(:closed_issue_event, project: @project)
@project.add_access current_user, :admin
end
......
......@@ -12,7 +12,7 @@ class DashboardSearch < Spinach::FeatureSteps
end
And 'I own project "Shop"' do
@project = create :project, name: "Shop"
@project = create(:project, :name => "Shop")
@project.add_access(@user, :admin)
end
......
......@@ -9,9 +9,9 @@ class Groups < Spinach::FeatureSteps
end
And 'I have group with projects' do
@group = Factory :group
@project = Factory :project, group: @group
@event = Factory :closed_issue_event, project: @project
@group = create(:group)
@project = create(:project, group: @group)
@event = create(:closed_issue_event, project: @project)
@project.add_access current_user, :admin
end
......
......@@ -53,7 +53,7 @@ class Profile < Spinach::FeatureSteps
end
Given 'I have activity' do
Factory :closed_issue_event, author: current_user
create(:closed_issue_event, author: current_user)
end
Then 'I should see my activity' do
......
......@@ -43,6 +43,6 @@ class ProfileSshKeys < Spinach::FeatureSteps
end
And 'I have ssh key "ssh-rsa Work"' do
Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work"
create(:key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work")
end
end
......@@ -6,7 +6,7 @@ class ProjectHooks < Spinach::FeatureSteps
include RSpec::Mocks::ExampleMethods
Given 'project has hook' do
@hook = Factory :project_hook, project: current_project
@hook = create(:project_hook, project: current_project)
end
Then 'I should see project hook' do
......
......@@ -79,16 +79,16 @@ class ProjectIssues < Spinach::FeatureSteps
Given 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop")
milestone = Factory :milestone, :title => "v2.2", :project => project
milestone = create(:milestone, :title => "v2.2", :project => project)
3.times { Factory :issue, :project => project, :milestone => milestone }
3.times { create(:issue, :project => project, :milestone => milestone) }
end
And 'project "Shop" has milestone "v3.0"' do
project = Project.find_by_name("Shop")
milestone = Factory :milestone, :title => "v3.0", :project => project
milestone = create(:milestone, :title => "v3.0", :project => project)
3.times { Factory :issue, :project => project, :milestone => milestone }
3.times { create(:issue, :project => project, :milestone => milestone) }
end
When 'I select milestone "v3.0"' do
......@@ -117,18 +117,18 @@ class ProjectIssues < Spinach::FeatureSteps
And 'project "Shop" have "Release 0.4" open issue' do
project = Project.find_by_name("Shop")
Factory.create(:issue,
:title => "Release 0.4",
:project => project,
:author => project.users.first)
create(:issue,
:title => "Release 0.4",
:project => project,
:author => project.users.first)
end
And 'project "Shop" have "Release 0.3" closed issue' do
project = Project.find_by_name("Shop")
Factory.create(:issue,
:title => "Release 0.3",
:project => project,
:author => project.users.first,
:closed => true)
create(:issue,
:title => "Release 0.3",
:project => project,
:author => project.users.first,
:closed => true)
end
end
......@@ -18,7 +18,7 @@ class ProjectLabels < Spinach::FeatureSteps
And 'project "Shop" have issues tags: "bug", "feature"' do
project = Project.find_by_name("Shop")
['bug', 'feature'].each do |label|
Factory :issue, project: project, label_list: label
create(:issue, project: project, label_list: label)
end
end
end
......@@ -63,18 +63,18 @@ class ProjectMergeRequests < Spinach::FeatureSteps
And 'project "Shop" have "Bug NS-04" open merge request' do
project = Project.find_by_name("Shop")
Factory.create(:merge_request,
:title => "Bug NS-04",
:project => project,
:author => project.users.first)
create(:merge_request,
:title => "Bug NS-04",
:project => project,
:author => project.users.first)
end
And 'project "Shop" have "Feature NS-03" closed merge request' do
project = Project.find_by_name("Shop")
Factory.create(:merge_request,
:title => "Feature NS-03",
:project => project,
:author => project.users.first,
:closed => true)
create(:merge_request,
:title => "Feature NS-03",
:project => project,
:author => project.users.first,
:closed => true)
end
end
......@@ -32,9 +32,9 @@ class ProjectMilestones < Spinach::FeatureSteps
And 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop")
milestone = Factory :milestone, :title => "v2.2", :project => project
milestone = create(:milestone, :title => "v2.2", :project => project)
3.times { Factory :issue, :project => project, :milestone => milestone }
3.times { create(:issue, :project => project, :milestone => milestone) }
end
Given 'the milestone has open and closed issues' do
......
......@@ -74,11 +74,11 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end
And 'gitlab user "Mike"' do
Factory :user, :name => "Mike"
create(:user, :name => "Mike")
end
And 'gitlab user "Sam"' do
Factory :user, :name => "Sam"
create(:user, :name => "Sam")
end
And '"Sam" is "Shop" developer' do
......@@ -88,7 +88,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end
Given 'I own project "Website"' do
@project = Factory :project, :name => "Website"
@project = create(:project, :name => "Website")
@project.add_access(@user, :admin)
end
......
......@@ -9,7 +9,7 @@ module SharedProject
# Create a specific project called "Shop"
And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop"
@project = create(:project, :name => "Shop")
@project.add_access(@user, :admin)
end
......
# Backwards compatibility with the old method
def Factory(type, *args)
FactoryGirl.create(type, *args)
end
module Factory
def self.create(type, *args)
FactoryGirl.create(type, *args)
end
def self.new(type, *args)
FactoryGirl.build(type, *args)
end
def self.attributes(type, *args)
FactoryGirl.attributes_for(type, *args)
end
end
FactoryGirl.define do
sequence :sentence, aliases: [:title, :content] do
Faker::Lorem.sentence
......
......@@ -4,8 +4,8 @@ describe Notify do
include EmailSpec::Helpers
include EmailSpec::Matchers
let(:recipient) { Factory.create(:user, email: 'recipient@example.com') }
let(:project) { Factory.create(:project) }
let(:recipient) { create(:user, email: 'recipient@example.com') }
let(:project) { create(:project) }
shared_examples 'a multiple recipients email' do
it 'is sent to the given recipient' do
......@@ -15,7 +15,7 @@ describe Notify do
describe 'for new users, the email' do
let(:example_site_path) { root_path }
let(:new_user) { Factory.create(:user, email: 'newguy@example.com') }
let(:new_user) { create(:user, email: 'newguy@example.com') }
subject { Notify.new_user_email(new_user.id, new_user.password) }
......@@ -42,8 +42,8 @@ describe Notify do
context 'for a project' do
describe 'items that are assignable, the email' do
let(:assignee) { Factory.create(:user, email: 'assignee@example.com') }
let(:previous_assignee) { Factory.create(:user, name: 'Previous Assignee') }
let(:assignee) { create(:user, email: 'assignee@example.com') }
let(:previous_assignee) { create(:user, name: 'Previous Assignee') }
shared_examples 'an assignee email' do
it 'is sent to the assignee' do
......@@ -52,7 +52,7 @@ describe Notify do
end
context 'for issues' do
let(:issue) { Factory.create(:issue, assignee: assignee, project: project ) }
let(:issue) { create(:issue, assignee: assignee, project: project ) }
describe 'that are new' do
subject { Notify.new_issue_email(issue.id) }
......@@ -93,10 +93,10 @@ describe Notify do
end
describe 'status changed' do
let(:current_user) { Factory.create :user, email: "current@email.com" }
let(:current_user) { create(:user, email: "current@email.com") }
let(:status) { 'closed' }
subject { Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user) }
it 'has the correct subject' do
should have_subject /changed issue ##{issue.id} \| #{issue.title}/i
end
......@@ -117,7 +117,7 @@ describe Notify do
end
context 'for merge requests' do
let(:merge_request) { Factory.create(:merge_request, assignee: assignee, project: project) }
let(:merge_request) { create(:merge_request, assignee: assignee, project: project) }
describe 'that are new' do
subject { Notify.new_merge_request_email(merge_request.id) }
......@@ -169,13 +169,13 @@ describe Notify do
end
describe 'project access changed' do
let(:project) { Factory.create(:project,
path: "Fuu",
code: "Fuu") }
let(:user) { Factory.create :user }
let(:users_project) { Factory.create(:users_project,
project: project,
user: user) }
let(:project) { create(:project,
path: "Fuu",
code: "Fuu") }
let(:user) { create(:user) }
let(:users_project) { create(:users_project,
project: project,
user: user) }
subject { Notify.project_access_granted_email(users_project.id) }
it 'has the correct subject' do
should have_subject /access to project was granted/
......@@ -189,8 +189,8 @@ describe Notify do
end
context 'items that are noteable, the email for a note' do
let(:note_author) { Factory.create(:user, name: 'author_name') }
let(:note) { Factory.create(:note, project: project, author: note_author) }
let(:note_author) { create(:user, name: 'author_name') }
let(:note) { create(:note, project: project, author: note_author) }
before :each do
Note.stub(:find).with(note.id).and_return(note)
......@@ -251,7 +251,7 @@ describe Notify do
end
describe 'on a merge request' do
let(:merge_request) { Factory.create(:merge_request, project: project) }
let(:merge_request) { create(:merge_request, project: project) }
let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") }
before(:each) { note.stub(:noteable).and_return(merge_request) }
......@@ -269,7 +269,7 @@ describe Notify do
end
describe 'on an issue' do
let(:issue) { Factory.create(:issue, project: project) }
let(:issue) { create(:issue, project: project) }
let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") }
before(:each) { note.stub(:noteable).and_return(issue) }
......
......@@ -32,7 +32,7 @@ describe Event do
describe "Push event" do
before do
project = Factory :project
project = create(:project)
@user = project.owner
data = {
......
......@@ -38,11 +38,11 @@ describe Issue do
it { should include_module(Votes) }
end
subject { Factory.create(:issue) }
subject { create(:issue) }
describe '#is_being_reassigned?' do
it 'returns true if the issue assignee has changed' do
subject.assignee = Factory(:user)
subject.assignee = create(:user)
subject.is_being_reassigned?.should be_true
end
it 'returns false if the issue assignee has not changed' do
......@@ -56,7 +56,7 @@ describe Issue do
subject.is_being_closed?.should be_true
end
it 'returns false if the closed attribute has changed and is now false' do
issue = Factory.create(:closed_issue)
issue = create(:closed_issue)
issue.closed = false
issue.is_being_closed?.should be_false
end
......@@ -68,7 +68,7 @@ describe Issue do
describe '#is_being_reopened?' do
it 'returns true if the closed attribute has changed and is now false' do
issue = Factory.create(:closed_issue)
issue = create(:closed_issue)
issue.closed = false
issue.is_being_reopened?.should be_true
end
......
......@@ -53,7 +53,7 @@ describe Key do
end
context "as a personal key" do
let(:user) { Factory.create(:user) }
let(:user) { create(:user) }
it "accepts the key once" do
build(:key, user: user).should be_valid
......@@ -67,7 +67,7 @@ describe Key do
end
context "validate it is a fingerprintable key" do
let(:user) { Factory.create(:user) }
let(:user) { create(:user) }
it "accepts the fingerprintable key" do
build(:key, user: user).should be_valid
......
......@@ -37,12 +37,12 @@ describe MergeRequest do
end
describe "#mr_and_commit_notes" do
let!(:merge_request) { Factory.create(:merge_request) }
let!(:merge_request) { create(:merge_request) }
before do
merge_request.stub(:commits) { [merge_request.project.commit] }
Factory.create(:note, noteable: merge_request.commits.first)
Factory.create(:note, noteable: merge_request)
create(:note, noteable: merge_request.commits.first)
create(:note, noteable: merge_request)
end
it "should include notes for commits" do
......@@ -51,11 +51,11 @@ describe MergeRequest do
end
end
subject { Factory.create(:merge_request) }
subject { create(:merge_request) }
describe '#is_being_reassigned?' do
it 'returns true if the merge_request assignee has changed' do
subject.assignee = Factory(:user)
subject.assignee = create(:user)
subject.is_being_reassigned?.should be_true
end
it 'returns false if the merge request assignee has not changed' do
......@@ -69,7 +69,7 @@ describe MergeRequest do
subject.is_being_closed?.should be_true
end
it 'returns false if the closed attribute has changed and is now false' do
merge_request = Factory.create(:closed_merge_request)
merge_request = create(:closed_merge_request)
merge_request.closed = false
merge_request.is_being_closed?.should be_false
end
......@@ -81,7 +81,7 @@ describe MergeRequest do
describe '#is_being_reopened?' do
it 'returns true if the closed attribute has changed and is now false' do
merge_request = Factory.create(:closed_merge_request)
merge_request = create(:closed_merge_request)
merge_request.closed = false
merge_request.is_being_reopened?.should be_true
end
......
......@@ -30,8 +30,8 @@ describe Milestone do
it { should ensure_inclusion_of(:closed).in_array([true, false]) }
end
let(:milestone) { Factory :milestone }
let(:issue) { Factory :issue }
let(:milestone) { create(:milestone) }
let(:issue) { create(:issue) }
describe "#percent_complete" do
it "should not count open issues" do
......
......@@ -40,10 +40,10 @@ describe Note do
end
describe "Voting score" do
let(:project) { Factory(:project) }
let(:project) { create(:project) }
it "recognizes a neutral note" do
note = Factory(:note, note: "This is not a +1 note")
note = create(:note, note: "This is not a +1 note")
note.should_not be_upvote
note.should_not be_downvote
end
......@@ -55,7 +55,7 @@ describe Note do
end
it "recognizes a +1 note" do
note = Factory(:note, note: "+1 for this")
note = create(:note, note: "+1 for this")
note.should be_upvote
end
......@@ -65,7 +65,7 @@ describe Note do
end
it "recognizes a -1 note" do
note = Factory(:note, note: "-1 for this")
note = create(:note, note: "-1 for this")
note.should be_downvote
end
......@@ -80,9 +80,9 @@ describe Note do
describe "Commit notes" do
before do
@note = Factory :note,
noteable_id: commit.id,
noteable_type: "Commit"
@note = create(:note,
noteable_id: commit.id,
noteable_type: "Commit")
end
it "should be accessible through #noteable" do
......@@ -103,10 +103,10 @@ describe Note do
describe "Pre-line commit notes" do
before do
@note = Factory :note,
noteable_id: commit.id,
noteable_type: "Commit",
line_code: "0_16_1"
@note = create(:note,
noteable_id: commit.id,
noteable_type: "Commit",
line_code: "0_16_1")
end
it "should save a valid note" do
......@@ -120,9 +120,9 @@ describe Note do
end
describe '#create_status_change_note' do
let(:project) { Factory.create(:project) }
let(:thing) { Factory.create(:issue, project: project) }
let(:author) { Factory(:user) }
let(:project) { create(:project) }
let(:thing) { create(:issue, project: project) }
let(:author) { create(:user) }
let(:status) { 'new_status' }
subject { Note.create_status_change_note(thing, author, status) }
......@@ -141,10 +141,10 @@ describe Note do
describe :authorization do
before do
@p1 = create(:project)
@p2 = Factory :project
@u1 = Factory :user
@u2 = Factory :user
@u3 = Factory :user
@p2 = create(:project)
@u1 = create(:user)
@u2 = create(:user)
@u3 = create(:user)
@abilities = Six.new
@abilities << Ability
end
......
require 'spec_helper'
describe Project, "Hooks" do
let(:project) { Factory :project }
before do
@key = Factory :key, user: project.owner
let(:project) { create(:project) }
before do
@key = create(:key, user: project.owner)
@user = @key.user
@key_id = @key.identifier
end
describe "Post Receive Event" do
it "should create push event" do
describe "Post Receive Event" do
it "should create push event" do
oldrev, newrev, ref = '00000000000000000000000000000000', 'newrev', 'refs/heads/master'
project.observe_push(oldrev, newrev, ref, @user)
event = Event.last
......@@ -32,8 +32,8 @@ describe Project, "Hooks" do
context "with web hooks" do
before do
@project_hook = Factory(:project_hook)
@project_hook_2 = Factory(:project_hook)
@project_hook = create(:project_hook)
@project_hook_2 = create(:project_hook)
project.hooks << [@project_hook, @project_hook_2]
end
......@@ -47,7 +47,7 @@ describe Project, "Hooks" do
context "does not execute web hooks" do
before do
@project_hook = Factory(:project_hook)
@project_hook = create(:project_hook)
project.hooks << [@project_hook]
end
......
......@@ -3,9 +3,9 @@ require 'spec_helper'
describe Project do
describe :authorization do
before do
@p1 = Factory :project
@u1 = Factory :user
@u2 = Factory :user
@p1 = create(:project)
@u1 = create(:user)
@u2 = create(:user)
@abilities = Six.new
@abilities << Ability
end
......
......@@ -157,7 +157,7 @@ describe Project do
describe :valid_repo? do
it "should be valid repo" do
project = Factory :project
project = create(:project)
project.valid_repo?.should be_true
end
......@@ -168,7 +168,7 @@ describe Project do
end
describe "last_activity methods" do
let(:project) { Factory :project }
let(:project) { create(:project) }
let(:last_event) { double(created_at: Time.now) }
describe "last_activity" do
......@@ -191,7 +191,7 @@ describe Project do
end
describe "fresh commits" do
let(:project) { Factory :project }
let(:project) { create(:project) }
it { project.fresh_commits(3).count.should == 3 }
it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" }
......@@ -199,7 +199,7 @@ describe Project do
end
describe "commits_between" do
let(:project) { Factory :project }
let(:project) { create(:project) }
subject do
commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff",
......@@ -213,7 +213,7 @@ describe Project do
end
describe "Git methods" do
let(:project) { Factory :project }
let(:project) { create(:project) }
describe :repo do
it "should return valid repo" do
......@@ -270,14 +270,14 @@ describe Project do
end
describe :update_merge_requests do
let(:project) { Factory :project }
let(:project) { create(:project) }
before do
@merge_request = Factory :merge_request,
project: project,
merged: false,
closed: false
@key = Factory :key, user_id: project.owner.id
@merge_request = create(:merge_request,
project: project,
merged: false,
closed: false)
@key = create(:key, user_id: project.owner.id)
end
it "should close merge request if last commit from source branch was pushed to target branch" do
......
......@@ -17,19 +17,19 @@ describe SystemHook do
before(:each) { ActiveRecord::Base.observers.enable(:all) }
before(:each) do
@system_hook = Factory :system_hook
@system_hook = create(:system_hook)
WebMock.stub_request(:post, @system_hook.url)
end
it "project_create hook" do
with_resque do
project = Factory :project
project = create(:project)
end
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once
end
it "project_destroy hook" do
project = Factory :project
project = create(:project)
with_resque do
project.destroy
end
......@@ -38,13 +38,13 @@ describe SystemHook do