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 ...@@ -32,7 +32,7 @@ class Dashboard < Spinach::FeatureSteps
end end
Given 'user with name "John Doe" joined project "Shop"' do 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" project = Project.find_by_name "Shop"
Event.create( Event.create(
project: project, project: project,
...@@ -65,9 +65,9 @@ class Dashboard < Spinach::FeatureSteps ...@@ -65,9 +65,9 @@ class Dashboard < Spinach::FeatureSteps
end end
And 'I have group with projects' do And 'I have group with projects' do
@group = create :group @group = create(:group)
@project = create :project, group: @group @project = create(:project, group: @group)
@event = create :closed_issue_event, project: @project @event = create(:closed_issue_event, project: @project)
@project.add_access current_user, :admin @project.add_access current_user, :admin
end end
......
...@@ -12,7 +12,7 @@ class DashboardSearch < Spinach::FeatureSteps ...@@ -12,7 +12,7 @@ class DashboardSearch < Spinach::FeatureSteps
end end
And 'I own project "Shop"' do And 'I own project "Shop"' do
@project = create :project, name: "Shop" @project = create(:project, :name => "Shop")
@project.add_access(@user, :admin) @project.add_access(@user, :admin)
end end
......
...@@ -9,9 +9,9 @@ class Groups < Spinach::FeatureSteps ...@@ -9,9 +9,9 @@ class Groups < Spinach::FeatureSteps
end end
And 'I have group with projects' do And 'I have group with projects' do
@group = Factory :group @group = create(:group)
@project = Factory :project, group: @group @project = create(:project, group: @group)
@event = Factory :closed_issue_event, project: @project @event = create(:closed_issue_event, project: @project)
@project.add_access current_user, :admin @project.add_access current_user, :admin
end end
......
...@@ -53,7 +53,7 @@ class Profile < Spinach::FeatureSteps ...@@ -53,7 +53,7 @@ class Profile < Spinach::FeatureSteps
end end
Given 'I have activity' do Given 'I have activity' do
Factory :closed_issue_event, author: current_user create(:closed_issue_event, author: current_user)
end end
Then 'I should see my activity' do Then 'I should see my activity' do
......
...@@ -43,6 +43,6 @@ class ProfileSshKeys < Spinach::FeatureSteps ...@@ -43,6 +43,6 @@ class ProfileSshKeys < Spinach::FeatureSteps
end end
And 'I have ssh key "ssh-rsa Work"' do 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
end end
...@@ -6,7 +6,7 @@ class ProjectHooks < Spinach::FeatureSteps ...@@ -6,7 +6,7 @@ class ProjectHooks < Spinach::FeatureSteps
include RSpec::Mocks::ExampleMethods include RSpec::Mocks::ExampleMethods
Given 'project has hook' do Given 'project has hook' do
@hook = Factory :project_hook, project: current_project @hook = create(:project_hook, project: current_project)
end end
Then 'I should see project hook' do Then 'I should see project hook' do
......
...@@ -79,16 +79,16 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -79,16 +79,16 @@ class ProjectIssues < Spinach::FeatureSteps
Given 'project "Shop" has milestone "v2.2"' do Given 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop") 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 end
And 'project "Shop" has milestone "v3.0"' do And 'project "Shop" has milestone "v3.0"' do
project = Project.find_by_name("Shop") 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 end
When 'I select milestone "v3.0"' do When 'I select milestone "v3.0"' do
...@@ -117,7 +117,7 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -117,7 +117,7 @@ class ProjectIssues < Spinach::FeatureSteps
And 'project "Shop" have "Release 0.4" open issue' do And 'project "Shop" have "Release 0.4" open issue' do
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
Factory.create(:issue, create(:issue,
:title => "Release 0.4", :title => "Release 0.4",
:project => project, :project => project,
:author => project.users.first) :author => project.users.first)
...@@ -125,7 +125,7 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -125,7 +125,7 @@ class ProjectIssues < Spinach::FeatureSteps
And 'project "Shop" have "Release 0.3" closed issue' do And 'project "Shop" have "Release 0.3" closed issue' do
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
Factory.create(:issue, create(:issue,
:title => "Release 0.3", :title => "Release 0.3",
:project => project, :project => project,
:author => project.users.first, :author => project.users.first,
......
...@@ -18,7 +18,7 @@ class ProjectLabels < Spinach::FeatureSteps ...@@ -18,7 +18,7 @@ class ProjectLabels < Spinach::FeatureSteps
And 'project "Shop" have issues tags: "bug", "feature"' do And 'project "Shop" have issues tags: "bug", "feature"' do
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
['bug', 'feature'].each do |label| ['bug', 'feature'].each do |label|
Factory :issue, project: project, label_list: label create(:issue, project: project, label_list: label)
end end
end end
end end
...@@ -63,7 +63,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -63,7 +63,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps
And 'project "Shop" have "Bug NS-04" open merge request' do And 'project "Shop" have "Bug NS-04" open merge request' do
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
Factory.create(:merge_request, create(:merge_request,
:title => "Bug NS-04", :title => "Bug NS-04",
:project => project, :project => project,
:author => project.users.first) :author => project.users.first)
...@@ -71,7 +71,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -71,7 +71,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps
And 'project "Shop" have "Feature NS-03" closed merge request' do And 'project "Shop" have "Feature NS-03" closed merge request' do
project = Project.find_by_name("Shop") project = Project.find_by_name("Shop")
Factory.create(:merge_request, create(:merge_request,
:title => "Feature NS-03", :title => "Feature NS-03",
:project => project, :project => project,
:author => project.users.first, :author => project.users.first,
......
...@@ -32,9 +32,9 @@ class ProjectMilestones < Spinach::FeatureSteps ...@@ -32,9 +32,9 @@ class ProjectMilestones < Spinach::FeatureSteps
And 'project "Shop" has milestone "v2.2"' do And 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop") 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 end
Given 'the milestone has open and closed issues' do Given 'the milestone has open and closed issues' do
......
...@@ -74,11 +74,11 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -74,11 +74,11 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
And 'gitlab user "Mike"' do And 'gitlab user "Mike"' do
Factory :user, :name => "Mike" create(:user, :name => "Mike")
end end
And 'gitlab user "Sam"' do And 'gitlab user "Sam"' do
Factory :user, :name => "Sam" create(:user, :name => "Sam")
end end
And '"Sam" is "Shop" developer' do And '"Sam" is "Shop" developer' do
...@@ -88,7 +88,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -88,7 +88,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
Given 'I own project "Website"' do Given 'I own project "Website"' do
@project = Factory :project, :name => "Website" @project = create(:project, :name => "Website")
@project.add_access(@user, :admin) @project.add_access(@user, :admin)
end end
......
...@@ -9,7 +9,7 @@ module SharedProject ...@@ -9,7 +9,7 @@ module SharedProject
# Create a specific project called "Shop" # Create a specific project called "Shop"
And 'I own project "Shop"' do And 'I own project "Shop"' do
@project = Factory :project, :name => "Shop" @project = create(:project, :name => "Shop")
@project.add_access(@user, :admin) @project.add_access(@user, :admin)
end 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 FactoryGirl.define do
sequence :sentence, aliases: [:title, :content] do sequence :sentence, aliases: [:title, :content] do
Faker::Lorem.sentence Faker::Lorem.sentence
......
...@@ -4,8 +4,8 @@ describe Notify do ...@@ -4,8 +4,8 @@ describe Notify do
include EmailSpec::Helpers include EmailSpec::Helpers
include EmailSpec::Matchers include EmailSpec::Matchers
let(:recipient) { Factory.create(:user, email: 'recipient@example.com') } let(:recipient) { create(:user, email: 'recipient@example.com') }
let(:project) { Factory.create(:project) } let(:project) { create(:project) }
shared_examples 'a multiple recipients email' do shared_examples 'a multiple recipients email' do
it 'is sent to the given recipient' do it 'is sent to the given recipient' do
...@@ -15,7 +15,7 @@ describe Notify do ...@@ -15,7 +15,7 @@ describe Notify do
describe 'for new users, the email' do describe 'for new users, the email' do
let(:example_site_path) { root_path } 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) } subject { Notify.new_user_email(new_user.id, new_user.password) }
...@@ -42,8 +42,8 @@ describe Notify do ...@@ -42,8 +42,8 @@ describe Notify do
context 'for a project' do context 'for a project' do
describe 'items that are assignable, the email' do describe 'items that are assignable, the email' do
let(:assignee) { Factory.create(:user, email: 'assignee@example.com') } let(:assignee) { create(:user, email: 'assignee@example.com') }
let(:previous_assignee) { Factory.create(:user, name: 'Previous Assignee') } let(:previous_assignee) { create(:user, name: 'Previous Assignee') }
shared_examples 'an assignee email' do shared_examples 'an assignee email' do
it 'is sent to the assignee' do it 'is sent to the assignee' do
...@@ -52,7 +52,7 @@ describe Notify do ...@@ -52,7 +52,7 @@ describe Notify do
end end
context 'for issues' do 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 describe 'that are new' do
subject { Notify.new_issue_email(issue.id) } subject { Notify.new_issue_email(issue.id) }
...@@ -93,7 +93,7 @@ describe Notify do ...@@ -93,7 +93,7 @@ describe Notify do
end end
describe 'status changed' do 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' } let(:status) { 'closed' }
subject { Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user) } subject { Notify.issue_status_changed_email(recipient.id, issue.id, status, current_user) }
...@@ -117,7 +117,7 @@ describe Notify do ...@@ -117,7 +117,7 @@ describe Notify do
end end
context 'for merge requests' do 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 describe 'that are new' do
subject { Notify.new_merge_request_email(merge_request.id) } subject { Notify.new_merge_request_email(merge_request.id) }
...@@ -169,11 +169,11 @@ describe Notify do ...@@ -169,11 +169,11 @@ describe Notify do
end end
describe 'project access changed' do describe 'project access changed' do
let(:project) { Factory.create(:project, let(:project) { create(:project,
path: "Fuu", path: "Fuu",
code: "Fuu") } code: "Fuu") }
let(:user) { Factory.create :user } let(:user) { create(:user) }
let(:users_project) { Factory.create(:users_project, let(:users_project) { create(:users_project,
project: project, project: project,
user: user) } user: user) }
subject { Notify.project_access_granted_email(users_project.id) } subject { Notify.project_access_granted_email(users_project.id) }
...@@ -189,8 +189,8 @@ describe Notify do ...@@ -189,8 +189,8 @@ describe Notify do
end end
context 'items that are noteable, the email for a note' do context 'items that are noteable, the email for a note' do
let(:note_author) { Factory.create(:user, name: 'author_name') } let(:note_author) { create(:user, name: 'author_name') }
let(:note) { Factory.create(:note, project: project, author: note_author) } let(:note) { create(:note, project: project, author: note_author) }
before :each do before :each do
Note.stub(:find).with(note.id).and_return(note) Note.stub(:find).with(note.id).and_return(note)
...@@ -251,7 +251,7 @@ describe Notify do ...@@ -251,7 +251,7 @@ describe Notify do
end end
describe 'on a merge request' do 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}") } 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) } before(:each) { note.stub(:noteable).and_return(merge_request) }
...@@ -269,7 +269,7 @@ describe Notify do ...@@ -269,7 +269,7 @@ describe Notify do
end end
describe 'on an issue' do 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}") } let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") }
before(:each) { note.stub(:noteable).and_return(issue) } before(:each) { note.stub(:noteable).and_return(issue) }
......
...@@ -32,7 +32,7 @@ describe Event do ...@@ -32,7 +32,7 @@ describe Event do
describe "Push event" do describe "Push event" do
before do before do
project = Factory :project project = create(:project)
@user = project.owner @user = project.owner
data = { data = {
......
...@@ -38,11 +38,11 @@ describe Issue do ...@@ -38,11 +38,11 @@ describe Issue do
it { should include_module(Votes) } it { should include_module(Votes) }
end end
subject { Factory.create(:issue) } subject { create(:issue) }
describe '#is_being_reassigned?' do describe '#is_being_reassigned?' do
it 'returns true if the issue assignee has changed' 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 subject.is_being_reassigned?.should be_true
end end
it 'returns false if the issue assignee has not changed' do it 'returns false if the issue assignee has not changed' do
...@@ -56,7 +56,7 @@ describe Issue do ...@@ -56,7 +56,7 @@ describe Issue do
subject.is_being_closed?.should be_true subject.is_being_closed?.should be_true
end end
it 'returns false if the closed attribute has changed and is now false' do 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.closed = false
issue.is_being_closed?.should be_false issue.is_being_closed?.should be_false
end end
...@@ -68,7 +68,7 @@ describe Issue do ...@@ -68,7 +68,7 @@ describe Issue do
describe '#is_being_reopened?' do describe '#is_being_reopened?' do
it 'returns true if the closed attribute has changed and is now false' 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.closed = false
issue.is_being_reopened?.should be_true issue.is_being_reopened?.should be_true
end end
......
...@@ -53,7 +53,7 @@ describe Key do ...@@ -53,7 +53,7 @@ describe Key do
end end
context "as a personal key" do context "as a personal key" do
let(:user) { Factory.create(:user) } let(:user) { create(:user) }
it "accepts the key once" do it "accepts the key once" do
build(:key, user: user).should be_valid build(:key, user: user).should be_valid
...@@ -67,7 +67,7 @@ describe Key do ...@@ -67,7 +67,7 @@ describe Key do
end end
context "validate it is a fingerprintable key" do context "validate it is a fingerprintable key" do
let(:user) { Factory.create(:user) } let(:user) { create(:user) }
it "accepts the fingerprintable key" do it "accepts the fingerprintable key" do
build(:key, user: user).should be_valid build(:key, user: user).should be_valid
......
...@@ -37,12 +37,12 @@ describe MergeRequest do ...@@ -37,12 +37,12 @@ describe MergeRequest do
end end
describe "#mr_and_commit_notes" do describe "#mr_and_commit_notes" do
let!(:merge_request) { Factory.create(:merge_request) } let!(:merge_request) { create(:merge_request) }
before do before do
merge_request.stub(:commits) { [merge_request.project.commit] } merge_request.stub(:commits) { [merge_request.project.commit] }
Factory.create(:note, noteable: merge_request.commits.first) create(:note, noteable: merge_request.commits.first)
Factory.create(:note, noteable: merge_request) create(:note, noteable: merge_request)
end end
it "should include notes for commits" do it "should include notes for commits" do
...@@ -51,11 +51,11 @@ describe MergeRequest do ...@@ -51,11 +51,11 @@ describe MergeRequest do
end end
end end
subject { Factory.create(:merge_request) } subject { create(:merge_request) }
describe '#is_being_reassigned?' do describe '#is_being_reassigned?' do
it 'returns true if the merge_request assignee has changed' 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 subject.is_being_reassigned?.should be_true
end end
it 'returns false if the merge request assignee has not changed' do it 'returns false if the merge request assignee has not changed' do
...@@ -69,7 +69,7 @@ describe MergeRequest do ...@@ -69,7 +69,7 @@ describe MergeRequest do
subject.is_being_closed?.should be_true subject.is_being_closed?.should be_true
end end
it 'returns false if the closed attribute has changed and is now false' do 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.closed = false
merge_request.is_being_closed?.should be_false merge_request.is_being_closed?.should be_false
end end
...@@ -81,7 +81,7 @@ describe MergeRequest do ...@@ -81,7 +81,7 @@ describe MergeRequest do
describe '#is_being_reopened?' do describe '#is_being_reopened?' do
it 'returns true if the closed attribute has changed and is now false' 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.closed = false
merge_request.is_being_reopened?.should be_true merge_request.is_being_reopened?.should be_true
end end
......
...@@ -30,8 +30,8 @@ describe Milestone do ...@@ -30,8 +30,8 @@ describe Milestone do
it { should ensure_inclusion_of(:closed).in_array([true, false]) } it { should ensure_inclusion_of(:closed).in_array([true, false]) }
end end
let(:milestone) { Factory :milestone } let(:milestone) { create(:milestone) }
let(:issue) { Factory :issue } let(:issue) { create(:issue) }
describe "#percent_complete" do describe "#percent_complete" do
it "should not count open issues" do it "should not count open issues" do
......
...@@ -40,10 +40,10 @@ describe Note do ...@@ -40,10 +40,10 @@ describe Note do
end end
describe "Voting score" do describe "Voting score" do
let(:project) { Factory(:project) } let(:project) { create(:project) }
it "recognizes a neutral note" do 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_upvote
note.should_not be_downvote note.should_not be_downvote
end end
...@@ -55,7 +55,7 @@ describe Note do ...@@ -55,7 +55,7 @@ describe Note do
end end
it "recognizes a +1 note" do it "recognizes a +1 note" do
note = Factory(:note, note: "+1 for this") note = create(:note, note: "+1 for this")
note.should be_upvote note.should be_upvote
end end
...@@ -65,7 +65,7 @@ describe Note do ...@@ -65,7 +65,7 @@ describe Note do
end end
it "recognizes a -1 note" do it "recognizes a -1 note" do
note = Factory(:note, note: "-1 for this") note = create(:note, note: "-1 for this")
note.should be_downvote note.should be_downvote
end end
...@@ -80,9 +80,9 @@ describe Note do ...@@ -80,9 +80,9 @@ describe Note do
describe "Commit notes" do describe "Commit notes" do
before do before do
@note = Factory :note, @note = create(:note,
noteable_id: commit.id, noteable_id: commit.id,
noteable_type: "Commit" noteable_type: "Commit")
end end
it "should be accessible through #noteable" do it "should be accessible through #noteable" do
...@@ -103,10 +103,10 @@ describe Note do ...@@ -103,10 +103,10 @@ describe Note do
describe "Pre-line commit notes" do describe "Pre-line commit notes" do
before do before do
@note = Factory :note, @note = create(:note,
noteable_id: commit.id, noteable_id: commit.id,
noteable_type: "Commit", noteable_type: "Commit",
line_code: "0_16_1" line_code: "0_16_1")
end end
it "should save a valid note" do it "should save a valid note" do
...@@ -120,9 +120,9 @@ describe Note do ...@@ -120,9 +120,9 @@ describe Note do
end end
describe '#create_status_change_note' do describe '#create_status_change_note' do
let(:project) { Factory.create(:project) } let(:project) { create(:project) }
let(:thing) { Factory.create(:issue, project: project) } let(:thing) { create(:issue, project: project) }
let(:author) { Factory(:user) } let(:author) { create(:user) }
let(:status) { 'new_status' } let(:status) { 'new_status' }
subject { Note.create_status_change_note(thing, author, status) } subject { Note.create_status_change_note(thing, author, status) }
...@@ -141,10 +141,10 @@ describe Note do ...@@ -141,10 +141,10 @@ describe Note do
describe :authorization do describe :authorization do
before do before do
@p1 = create(:project) @p1 = create(:project)
@p2 = Factory :project @p2 = create(:project)
@u1 = Factory :user @u1 = create(:user)
@u2 = Factory :user @u2 = create(:user)
@u3 = Factory :user @u3 = create(:user)
@abilities = Six.new @abilities = Six.new
@abilities << Ability @abilities << Ability
end end
......
require 'spec_helper' require 'spec_helper'
describe Project, "Hooks" do describe Project, "Hooks" do
let(:project) { Factory :project } let(:project) { create(:project) }
before do before do
@key = Factory :key, user: project.owner @key = create(:key, user: project.owner)
@user = @key.user @user = @key.user
@key_id = @key.identifier @key_id = @key.identifier
end end
...@@ -32,8 +32,8 @@ describe Project, "Hooks" do ...@@ -32,8 +32,8 @@ describe Project, "Hooks" do
context "with web hooks" do context "with web hooks" do
before do before do
@project_hook = Factory(:project_hook) @project_hook = create(:project_hook)
@project_hook_2 = Factory(:project_hook) @project_hook_2 = create(:project_hook)
project.hooks << [@project_hook, @project_hook_2] project.hooks << [@project_hook, @project_hook_2]
end end
...@@ -47,7 +47,7 @@ describe Project, "Hooks" do ...@@ -47,7 +47,7 @@ describe Project, "Hooks" do
context "does not execute web hooks" do context "does not execute web hooks" do
before do before do
@project_hook = Factory(:project_hook) @project_hook = create(:project_hook)
project.hooks << [@project_hook] project.hooks << [@project_hook]
end end
......
...@@ -3,9 +3,9 @@ require 'spec_helper' ...@@ -3,9 +3,9 @@ require 'spec_helper'
describe Project do describe Project do
describe :authorization do describe :authorization do
before do before do
@p1 = Factory :project @p1 = create(:project)
@u1 = Factory :user @u1 = create(:user)
@u2 = Factory :user @u2 = create(:user)
@abilities = Six.new @abilities = Six.new
@abilities << Ability @abilities << Ability
end end
......
...@@ -157,7 +157,7 @@ describe Project do ...@@ -157,7 +157,7 @@ describe Project do
describe :valid_repo? do describe :valid_repo? do
it "should be valid repo" do it "should be valid repo" do
project = Factory :project project = create(:project)
project.valid_repo?.should be_true project.valid_repo?.should be_true
end end
...@@ -168,7 +168,7 @@ describe Project do ...@@ -168,7 +168,7 @@ describe Project do
end end
describe "last_activity methods" do describe "last_activity methods" do
let(:project) { Factory :project } let(:project) { create(:project) }
let(:last_event) { double(created_at: Time.now) } let(:last_event) { double(created_at: Time.now) }
describe "last_activity" do describe "last_activity" do
...@@ -191,7 +191,7 @@ describe Project do ...@@ -191,7 +191,7 @@ describe Project do
end end
describe "fresh commits" do describe "fresh commits" do
let(:project) { Factory :project } let(:project) { create(:project) }
it { project.fresh_commits(3).count.should == 3 } it { project.fresh_commits(3).count.should == 3 }
it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" } it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" }
...@@ -199,7 +199,7 @@ describe Project do ...@@ -199,7 +199,7 @@ describe Project do
end end
describe "commits_between" do describe "commits_between" do
let(:project) { Factory :project } let(:project) { create(:project) }
subject do subject do
commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff", commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff",
...@@ -213,7 +213,7 @@ describe Project do ...@@ -213,7 +213,7 @@ describe Project do
end end
describe "Git methods" do describe "Git methods" do
let(:project) { Factory :project } let(:project) { create(:project) }
describe :repo do describe :repo do
it "should return valid repo" do it "should return valid repo" do
...@@ -270,14 +270,14 @@ describe Project do ...@@ -270,14 +270,14 @@ describe Project do
end end
describe :update_merge_requests do describe :update_merge_requests do
let(:project) { Factory :project } let(:project) { create(:project) }
before do before do
@merge_request = Factory :merge_request, @merge_request = create(:merge_request,
project: project, project: project,
merged: false, merged: false,
closed: false closed: false)
@key = Factory :key, user_id: project.owner.id @key = create(:key, user_id: project.owner.id)
end end
it "should close merge request if last commit from source branch was pushed to target branch" do it "should close merge request if last commit from source branch was pushed to target branch" do
......
...@@ -17,19 +17,19 @@ describe SystemHook do ...@@ -17,19 +17,19 @@ describe SystemHook do
before(:each) { ActiveRecord::Base.observers.enable(:all) } before(:each) { ActiveRecord::Base.observers.enable(:all) }
before(:each) do before(:each) do
@system_hook = Factory :system_hook @system_hook = create(:system_hook)
WebMock.stub_request(:post, @system_hook.url) WebMock.stub_request(:post, @system_hook.url)
end end
it "project_create hook" do it "project_create hook" do
with_resque do with_resque do
project = Factory :project project = create(:project)
end end
WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once
end end
it "project_destroy hook" do it "project_destroy hook" do
project = Factory :project project = create(:project)
with_resque do with_resque do
project.destroy project.destroy
end end
...@@ -38,13 +38,13 @@ describe SystemHook do ...@@ -38,13 +38,13 @@ describe SystemHook do
it "user_create hook" do it "user_create hook" do
with_resque do with_resque do
Factory :user create(:user)
end end
WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once
end end
it "user_destroy hook" do it "user_destroy hook" do
user = Factory :user user = create(:user)
with_resque do with_resque do
user.destroy user.destroy
end end
...@@ -52,8 +52,8 @@ describe SystemHook do ...@@ -52,8 +52,8 @@ describe SystemHook do
end end
it "project_create hook" do it "project_create hook" do
user = Factory :user user = create(:user)
project = Factory :project project = create(:project)
with_resque do with_resque do
project.users << user project.users << user
end end
...@@ -61,8 +61,8 @@ describe SystemHook do ...@@ -61,8 +61,8 @@ describe SystemHook do
end end
it "project_destroy hook" do it "project_destroy hook" do
user = Factory :user user = create(:user)
project = Factory :project project = create(:project)
project.users << user project.users << user
with_resque do with_resque do
project.users_projects.clear project.users_projects.clear
......
...@@ -108,7 +108,7 @@ describe User do ...@@ -108,7 +108,7 @@ describe User do
describe 'authentication token' do describe 'authentication token' do
it "should have authentication token" do it "should have authentication token" do
user = Factory(:user) user = create(:user)
user.authentication_token.should_not be_blank user.authentication_token.should_not be_blank
end end
end end
......
...@@ -39,8 +39,8 @@ describe ProjectHook do ...@@ -39,8 +39,8 @@ describe ProjectHook do
describe "execute" do describe "execute" do
before(:each) do before(:each) do
@project_hook = Factory :project_hook @project_hook = create(:project_hook)
@project = Factory :project @project = create(:project)
@project.hooks << [@project_hook] @project.hooks << [@project_hook]
@data = { before: 'oldrev', after: 'newrev', ref: 'ref'} @data = { before: 'oldrev', after: 'newrev', ref: 'ref'}
......
require 'spec_helper' require 'spec_helper'
describe ActivityObserver do describe ActivityObserver do
let(:project) { Factory :project } let(:project) { create(:project) }
def self.it_should_be_valid_event def self.it_should_be_valid_event
it { @event.should_not be_nil } it { @event.should_not be_nil }
...@@ -11,7 +11,7 @@ describe ActivityObserver do ...@@ -11,7 +11,7 @@ describe ActivityObserver do
describe "Merge Request created" do describe "Merge Request created" do
before do before do
MergeRequest.observers.enable :activity_observer do MergeRequest.observers.enable :activity_observer do
@merge_request = Factory :merge_request, project: project @merge_request = create(:merge_request, project: project)
@event = Event.last @event = Event.last
end end
end end
...@@ -24,7 +24,7 @@ describe ActivityObserver do ...@@ -24,7 +24,7 @@ describe ActivityObserver do
describe "Issue created" do describe "Issue created" do
before do before do
Issue.observers.enable :activity_observer do Issue.observers.enable :activity_observer do
@issue = Factory :issue, project: project @issue = create(:issue, project: project)
@event = Event.last @event = Event.last
end end
end end
...@@ -36,8 +36,8 @@ describe ActivityObserver do ...@@ -36,8 +36,8 @@ describe ActivityObserver do
#describe "Issue commented" do #describe "Issue commented" do
#before do #before do
#@issue = Factory :issue, project: project #@issue = create(:issue, project: project)
#@note = Factory :note, noteable: @issue, project: project #@note = create(:note, noteable: @issue, project: project)
#@event = Event.last #@event = Event.last
#end #end
......
...@@ -16,7 +16,7 @@ describe IssueObserver do ...@@ -16,7 +16,7 @@ describe IssueObserver do
subject.should_receive(:after_create) subject.should_receive(:after_create)
Issue.observers.enable :issue_observer do Issue.observers.enable :issue_observer do
Factory.create(:issue, project: Factory.create(:project)) create(:issue, project: create(:project))
end end
end end
...@@ -43,7 +43,7 @@ describe IssueObserver do ...@@ -43,7 +43,7 @@ describe IssueObserver do
end end
it 'is called when an issue is changed' do it 'is called when an issue is changed' do
changed = Factory.create(:issue, project: Factory.create(:project)) changed = create(:issue, project: create(:project))
subject.should_receive(:after_update) subject.should_receive(:after_update)
Issue.observers.enable :issue_observer do Issue.observers.enable :issue_observer do
......
...@@ -16,7 +16,7 @@ describe MergeRequestObserver do ...@@ -16,7 +16,7 @@ describe MergeRequestObserver do
subject.should_receive(:after_create) subject.should_receive(:after_create)
MergeRequest.observers.enable :merge_request_observer do MergeRequest.observers.enable :merge_request_observer do
Factory.create(:merge_request, project: Factory.create(:project)) create(:merge_request, project: create(:project))
end end
end end
...@@ -43,7 +43,7 @@ describe MergeRequestObserver do ...@@ -43,7 +43,7 @@ describe MergeRequestObserver do
end end
it 'is called when a merge request is changed' do it 'is called when a merge request is changed' do
changed = Factory.create(:merge_request, project: Factory.create(:project)) changed = create(:merge_request, project: create(:project))
subject.should_receive(:after_update) subject.should_receive(:after_update)
MergeRequest.observers.enable :merge_request_observer do MergeRequest.observers.enable :merge_request_observer do
......
...@@ -13,7 +13,7 @@ describe NoteObserver do ...@@ -13,7 +13,7 @@ describe NoteObserver do
subject.should_receive :after_create subject.should_receive :after_create
Note.observers.enable :note_observer do Note.observers.enable :note_observer do
Factory.create(:note) create(:note)
end end
end end
......
...@@ -4,7 +4,7 @@ describe UserObserver do ...@@ -4,7 +4,7 @@ describe UserObserver do
subject { UserObserver.instance } subject { UserObserver.instance }
it 'calls #after_create when new users are created' do it 'calls #after_create when new users are created' do
new_user = Factory.new(:user) new_user = build(:user)
subject.should_receive(:after_create).with(new_user) subject.should_receive(:after_create).with(new_user)
User.observers.enable :user_observer do User.observers.enable :user_observer do
......
require 'spec_helper' require 'spec_helper'
describe UsersProjectObserver do describe UsersProjectObserver do
let(:user) { Factory.create :user } let(:user) { create(:user) }
let(:project) { Factory.create(:project, let(:project) { create(:project,
code: "Fuu", code: "Fuu",
path: "Fuu" ) } path: "Fuu" ) }
let(:users_project) { Factory.create(:users_project, let(:users_project) { create(:users_project,
project: project, project: project,
user: user )} user: user )}
subject { UsersProjectObserver.instance } subject { UsersProjectObserver.instance }
......
...@@ -2,12 +2,12 @@ require 'spec_helper' ...@@ -2,12 +2,12 @@ require 'spec_helper'
describe "Admin::Hooks" do describe "Admin::Hooks" do
before do before do
@project = Factory :project, @project = create(:project,
name: "LeGiT", name: "LeGiT",
code: "LGT" code: "LGT")
login_as :admin login_as :admin
@system_hook = Factory :system_hook @system_hook = create(:system_hook)
end end
......
...@@ -2,9 +2,9 @@ require 'spec_helper' ...@@ -2,9 +2,9 @@ require 'spec_helper'
describe "Admin::Projects" do describe "Admin::Projects" do
before do before do
@project = Factory :project, @project = create(:project,
name: "LeGiT", name: "LeGiT",
code: "LGT" code: "LGT")
login_as :admin login_as :admin
end end
...@@ -104,7 +104,7 @@ describe "Admin::Projects" do ...@@ -104,7 +104,7 @@ describe "Admin::Projects" do
describe "Add new team member" do describe "Add new team member" do
before do before do
@new_user = Factory :user @new_user = create(:user)
visit admin_project_path(@project) visit admin_project_path(@project)
end end
......
...@@ -76,7 +76,7 @@ describe "Admin::Users" do ...@@ -76,7 +76,7 @@ describe "Admin::Users" do
describe "GET /admin/users/:id/edit" do describe "GET /admin/users/:id/edit" do
before do before do
@simple_user = Factory :user @simple_user = create(:user)
visit admin_users_path visit admin_users_path
click_link "edit_user_#{@simple_user.id}" click_link "edit_user_#{@simple_user.id}"
end end
...@@ -109,7 +109,7 @@ describe "Admin::Users" do ...@@ -109,7 +109,7 @@ describe "Admin::Users" do
describe "Add new project" do describe "Add new project" do
before do before do
@new_project = Factory :project @new_project = create(:project)
visit admin_user_path(@user) visit admin_user_path(@user)
end end
......
...@@ -3,9 +3,9 @@ require 'spec_helper' ...@@ -3,9 +3,9 @@ require 'spec_helper'
describe Gitlab::API do describe Gitlab::API do
include ApiHelpers include ApiHelpers
let(:user) { Factory :user } let(:user) { create(:user) }
let!(:project) { Factory :project, owner: user } let!(:project) { create(:project, owner: user) }
let!(:issue) { Factory :issue, author: user, assignee: user, project: project } let!(:issue) { create(:issue, author: user, assignee: user, project: project) }
before { project.add_access(user, :read) } before { project.add_access(user, :read) }
describe "GET /issues" do describe "GET /issues" do
......
...@@ -3,9 +3,9 @@ require "spec_helper" ...@@ -3,9 +3,9 @@ require "spec_helper"
describe Gitlab::API do describe Gitlab::API do
include ApiHelpers include ApiHelpers
let(:user) { Factory :user } let(:user) { create(:user ) }
let!(:project) { Factory :project, owner: user } let!(:project) { create(:project, owner: user) }
let!(:merge_request) { Factory :merge_request, author: user, assignee: user, project: project, title: "Test" } let!(:merge_request) { create(:merge_request, author: user, assignee: user, project: project, title: "Test") }
before { project.add_access(user, :read) } before { project.add_access(user, :read) }
describe "GET /projects/:id/merge_requests" do describe "GET /projects/:id/merge_requests" do
......
...@@ -3,9 +3,9 @@ require 'spec_helper' ...@@ -3,9 +3,9 @@ require 'spec_helper'
describe Gitlab::API do describe Gitlab::API do
include ApiHelpers include ApiHelpers
let(:user) { Factory :user } let(:user) { create(:user) }
let!(:project) { Factory :project, owner: user } let!(:project) { create(:project, owner: user) }
let!(:milestone) { Factory :milestone, project: project } let!(:milestone) { create(:milestone, project: project) }
before { project.add_access(user, :read) } before { project.add_access(user, :read) }
......
...@@ -3,14 +3,14 @@ require 'spec_helper' ...@@ -3,14 +3,14 @@ require 'spec_helper'
describe Gitlab::API do describe Gitlab::API do
include ApiHelpers include ApiHelpers
let(:user) { Factory :user } let(:user) { create(:user) }
let(:user2) { Factory.create(:user) } let(:user2) { create(:user) }
let(:user3) { Factory.create(:user) } let(:user3) { create(:user) }
let!(:hook) { Factory :project_hook, project: project, url: "http://example.com" } let!(:hook) { create(:project_hook, project: project, url: "http://example.com") }
let!(:project) { Factory :project, owner: user } let!(:project) { create(:project, owner: user ) }
let!(:snippet) { Factory :snippet, author: user, project: project, title: 'example' } let!(:snippet) { create(:snippet, author: user, project: project, title: 'example') }
let!(:users_project) { Factory :users_project, user: user, project: project, project_access: UsersProject::MASTER } let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) }
let!(:users_project2) { Factory :users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER } let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) }
before { project.add_access(user, :read) } before { project.add_access(user, :read) }
describe "GET /projects" do describe "GET /projects" do
...@@ -52,7 +52,7 @@ describe Gitlab::API do ...@@ -52,7 +52,7 @@ describe Gitlab::API do
end end
it "should assign attributes to project" do it "should assign attributes to project" do
project = Factory.attributes(:project, { project = attributes_for(:project, {
path: 'path', path: 'path',
code: 'code', code: 'code',
description: Faker::Lorem.sentence, description: Faker::Lorem.sentence,
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe Gitlab::API do describe Gitlab::API do
include ApiHelpers include ApiHelpers
let(:user) { Factory :user } let(:user) { create(:user) }
describe "POST /session" do describe "POST /session" do
context "when valid password" do context "when valid password" do
......
...@@ -3,9 +3,9 @@ require 'spec_helper' ...@@ -3,9 +3,9 @@ require 'spec_helper'
describe Gitlab::API do describe Gitlab::API do
include ApiHelpers include ApiHelpers
let(:user) { Factory :user } let(:user) { create(:user) }
let(:admin) { Factory :admin } let(:admin) { create(:admin) }
let(:key) { Factory :key, user: user } let(:key) { create(:key, user: user) }
describe "GET /users" do describe "GET /users" do
context "when unauthenticated" do context "when unauthenticated" do
...@@ -43,12 +43,12 @@ describe Gitlab::API do ...@@ -43,12 +43,12 @@ describe Gitlab::API do
it "should create user" do it "should create user" do
expect { expect {
post api("/users", admin), Factory.attributes(:user, projects_limit: 3) post api("/users", admin), attributes_for(:user, projects_limit: 3)
}.to change { User.count }.by(1) }.to change { User.count }.by(1)
end end
it "shouldn't available for non admin users" do it "shouldn't available for non admin users" do
post api("/users", user), Factory.attributes(:user) post api("/users", user), attributes_for(:user)
response.status.should == 403 response.status.should == 403
end end
end end
...@@ -103,7 +103,7 @@ describe Gitlab::API do ...@@ -103,7 +103,7 @@ describe Gitlab::API do
end end
it "should create ssh key" do it "should create ssh key" do
key_attrs = Factory.attributes :key key_attrs = attributes_for :key
expect { expect {
post api("/user/keys", user), key_attrs post api("/user/keys", user), key_attrs
}.to change{ user.keys.count }.by(1) }.to change{ user.keys.count }.by(1)
......
...@@ -2,11 +2,11 @@ require 'spec_helper' ...@@ -2,11 +2,11 @@ require 'spec_helper'
describe "Dashboard Issues Feed" do describe "Dashboard Issues Feed" do
describe "GET /issues" do describe "GET /issues" do
let!(:user) { Factory :user } let!(:user) { create(:user) }
let!(:project1) { Factory :project } let!(:project1) { create(:project) }
let!(:project2) { Factory :project } let!(:project2) { create(:project) }
let!(:issue1) { Factory :issue, author: user, assignee: user, project: project1 } let!(:issue1) { create(:issue, author: user, assignee: user, project: project1) }
let!(:issue2) { Factory :issue, author: user, assignee: user, project: project2 } let!(:issue2) { create(:issue, author: user, assignee: user, project: project2) }
describe "atom feed" do describe "atom feed" do
it "should render atom feed via private token" do it "should render atom feed via private token" do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe "Dashboard Feed" do describe "Dashboard Feed" do
describe "GET /" do describe "GET /" do
let!(:user) { Factory :user } let!(:user) { create(:user) }
context "projects atom feed via private token" do context "projects atom feed via private token" do
it "should render projects atom feed" do it "should render projects atom feed" do
......
...@@ -2,9 +2,9 @@ require 'spec_helper' ...@@ -2,9 +2,9 @@ require 'spec_helper'
describe "Issues Feed" do describe "Issues Feed" do
describe "GET /issues" do describe "GET /issues" do
let!(:user) { Factory :user } let!(:user) { create(:user) }
let!(:project) { Factory :project, owner: user } let!(:project) { create(:project, owner: user) }
let!(:issue) { Factory :issue, author: user, project: project } let!(:issue) { create(:issue, author: user, project: project) }
before { project.add_access(user, :read, :write) } before { project.add_access(user, :read, :write) }
......
require 'spec_helper' require 'spec_helper'
describe "Gitlab Flavored Markdown" do describe "Gitlab Flavored Markdown" do
let(:project) { Factory :project } let(:project) { create(:project) }
let(:issue) { Factory :issue, project: project } let(:issue) { create(:issue, project: project) }
let(:merge_request) { Factory :merge_request, project: project } let(:merge_request) { create(:merge_request, project: project) }
let(:fred) do let(:fred) do
u = Factory :user, name: "fred" u = create(:user, name: "fred")
project.users << u project.users << u
u u
end end
...@@ -84,16 +84,16 @@ describe "Gitlab Flavored Markdown" do ...@@ -84,16 +84,16 @@ describe "Gitlab Flavored Markdown" do
describe "for issues" do describe "for issues" do
before do before do
@other_issue = Factory :issue, @other_issue = create(:issue,
author: @user, author: @user,
assignee: @user, assignee: @user,
project: project project: project)
@issue = Factory :issue, @issue = create(:issue,
author: @user, author: @user,
assignee: @user, assignee: @user,
project: project, project: project,
title: "fix ##{@other_issue.id}", title: "fix ##{@other_issue.id}",
description: "ask @#{fred.name} for details" description: "ask @#{fred.name} for details")
end end
it "should render subject in issues#index" do it "should render subject in issues#index" do
...@@ -118,9 +118,9 @@ describe "Gitlab Flavored Markdown" do ...@@ -118,9 +118,9 @@ describe "Gitlab Flavored Markdown" do
describe "for merge requests" do describe "for merge requests" do
before do before do
@merge_request = Factory :merge_request, @merge_request = create(:merge_request,
project: project, project: project,
title: "fix ##{issue.id}" title: "fix ##{issue.id}")
end end
it "should render title in merge_requests#index" do it "should render title in merge_requests#index" do
...@@ -139,10 +139,10 @@ describe "Gitlab Flavored Markdown" do ...@@ -139,10 +139,10 @@ describe "Gitlab Flavored Markdown" do
describe "for milestones" do describe "for milestones" do
before do before do
@milestone = Factory :milestone, @milestone = create(:milestone,
project: project, project: project,
title: "fix ##{issue.id}", title: "fix ##{issue.id}",
description: "ask @#{fred.name} for details" description: "ask @#{fred.name} for details")
end end
it "should render title in milestones#index" do it "should render title in milestones#index" do
......
require 'spec_helper' require 'spec_helper'
describe "Issues" do describe "Issues" do
let(:project) { Factory :project } let(:project) { create(:project) }
before do before do
login_as :user login_as :user
@user2 = Factory :user @user2 = create(:user)
project.add_access(@user, :read, :write) project.add_access(@user, :read, :write)
project.add_access(@user2, :read, :write) project.add_access(@user2, :read, :write)
...@@ -13,10 +13,10 @@ describe "Issues" do ...@@ -13,10 +13,10 @@ describe "Issues" do
describe "Edit issue", js: true do describe "Edit issue", js: true do
before do before do
@issue = Factory :issue, @issue = create(:issue,
author: @user, author: @user,
assignee: @user, assignee: @user,
project: project project: project)
visit project_issues_path(project) visit project_issues_path(project)
click_link "Edit" click_link "Edit"
end end
...@@ -46,11 +46,11 @@ describe "Issues" do ...@@ -46,11 +46,11 @@ describe "Issues" do
describe "Search issue", js: true do describe "Search issue", js: true do
before do before do
['foobar', 'foobar2', 'gitlab'].each do |title| ['foobar', 'foobar2', 'gitlab'].each do |title|
@issue = Factory :issue, @issue = create(:issue,
author: @user, author: @user,
assignee: @user, assignee: @user,
project: project, project: project,
title: title title: title)
@issue.save @issue.save
end end
end end
...@@ -93,15 +93,15 @@ describe "Issues" do ...@@ -93,15 +93,15 @@ describe "Issues" do
describe "Filter issue" do describe "Filter issue" do
before do before do
['foobar', 'barbaz', 'gitlab'].each do |title| ['foobar', 'barbaz', 'gitlab'].each do |title|
@issue = Factory :issue, @issue = create(:issue,
author: @user, author: @user,
assignee: @user, assignee: @user,
project: project, project: project,
title: title title: title)
end end
@issue = Issue.first @issue = Issue.first
@issue.milestone = Factory(:milestone, project: project) @issue.milestone = create(:milestone, project: project)
@issue.assignee = nil @issue.assignee = nil
@issue.save @issue.save
end end
......
require 'spec_helper' require 'spec_helper'
describe "Projects", "DeployKeys" do describe "Projects", "DeployKeys" do
let(:project) { Factory :project } let(:project) { create(:project) }
before do before do
login_as :user login_as :user
...@@ -10,7 +10,7 @@ describe "Projects", "DeployKeys" do ...@@ -10,7 +10,7 @@ describe "Projects", "DeployKeys" do
describe "GET /keys" do describe "GET /keys" do
before do before do
@key = Factory :key, project: project @key = create(:key, project: project)
visit project_deploy_keys_path(project) visit project_deploy_keys_path(project)
end end
...@@ -57,7 +57,7 @@ describe "Projects", "DeployKeys" do ...@@ -57,7 +57,7 @@ describe "Projects", "DeployKeys" do
describe "Show page" do describe "Show page" do
before do before do
@key = Factory :key, project: project @key = create(:key, project: project)
visit project_deploy_key_path(project, @key) visit project_deploy_key_path(project, @key)
end end
......
...@@ -15,7 +15,7 @@ describe "Projects" do ...@@ -15,7 +15,7 @@ describe "Projects" do
describe "GET /projects/show" do describe "GET /projects/show" do
before do before do
@project = Factory :project, owner: @user @project = create(:project, owner: @user)
@project.add_access(@user, :read) @project.add_access(@user, :read)
visit project_path(@project) visit project_path(@project)
...@@ -28,7 +28,7 @@ describe "Projects" do ...@@ -28,7 +28,7 @@ describe "Projects" do
describe "GET /projects/:id/edit" do describe "GET /projects/:id/edit" do
before do before do
@project = Factory :project @project = create(:project)
@project.add_access(@user, :admin, :read) @project.add_access(@user, :admin, :read)
visit edit_project_path(@project) visit edit_project_path(@project)
...@@ -47,7 +47,7 @@ describe "Projects" do ...@@ -47,7 +47,7 @@ describe "Projects" do
describe "PUT /projects/:id" do describe "PUT /projects/:id" do
before do before do
@project = Factory :project, owner: @user @project = create(:project, owner: @user)
@project.add_access(@user, :admin, :read) @project.add_access(@user, :admin, :read)
visit edit_project_path(@project) visit edit_project_path(@project)
...@@ -69,7 +69,7 @@ describe "Projects" do ...@@ -69,7 +69,7 @@ describe "Projects" do
describe "DELETE /projects/:id" do describe "DELETE /projects/:id" do
before do before do
@project = Factory :project @project = create(:project)
@project.add_access(@user, :read, :admin) @project.add_access(@user, :read, :admin)
visit edit_project_path(@project) visit edit_project_path(@project)
end end
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe "Search" do describe "Search" do
before do before do
login_as :user login_as :user
@project = Factory :project @project = create(:project)
@project.add_access(@user, :read) @project.add_access(@user, :read)
visit search_path visit search_path
fill_in "search", with: @project.name[0..3] fill_in "search", with: @project.name[0..3]
......
...@@ -3,7 +3,7 @@ require 'spec_helper' ...@@ -3,7 +3,7 @@ require 'spec_helper'
describe "Users Security" do describe "Users Security" do
describe "Project" do describe "Project" do
before do before do
@u1 = Factory :user @u1 = create(:user)
end end
describe "GET /login" do describe "GET /login" do
......
require 'spec_helper' require 'spec_helper'
describe "Snippets" do describe "Snippets" do
let(:project) { Factory :project } let(:project) { create(:project) }
before do before do
login_as :user login_as :user
...@@ -10,9 +10,9 @@ describe "Snippets" do ...@@ -10,9 +10,9 @@ describe "Snippets" do
describe "GET /snippets" do describe "GET /snippets" do
before do before do
@snippet = Factory :snippet, @snippet = create(:snippet,
author: @user, author: @user,
project: project project: project)
visit project_snippets_path(project) visit project_snippets_path(project)
end end
...@@ -68,9 +68,9 @@ describe "Snippets" do ...@@ -68,9 +68,9 @@ describe "Snippets" do
describe "Edit snippet" do describe "Edit snippet" do
before do before do
@snippet = Factory :snippet, @snippet = create(:snippet,
author: @user, author: @user,
project: project project: project)
visit project_snippet_path(project, @snippet) visit project_snippet_path(project, @snippet)
click_link "Edit" click_link "Edit"
end end
......
...@@ -3,7 +3,7 @@ module LoginHelpers ...@@ -3,7 +3,7 @@ module LoginHelpers
# #
# role - User role (e.g., :admin, :user) # role - User role (e.g., :admin, :user)
def login_as(role) def login_as(role)
@user = Factory(role) @user = create(role)
login_with(@user) login_with(@user)
end end
......
...@@ -59,9 +59,9 @@ module UrlAccess ...@@ -59,9 +59,9 @@ module UrlAccess
def emulate_user(user) def emulate_user(user)
user = case user user = case user
when :user then Factory(:user) when :user then create(:user)
when :visitor then nil when :visitor then nil
when :admin then Factory(:admin) when :admin then create(:admin)
else user else user
end end
login_with(user) if user login_with(user) if user
......
...@@ -9,8 +9,8 @@ describe PostReceive do ...@@ -9,8 +9,8 @@ describe PostReceive do
end end
context "web hook" do context "web hook" do
let(:project) { Factory.create(:project) } let(:project) { create(:project) }
let(:key) { Factory.create(:key, user: project.owner) } let(:key) { create(:key, user: project.owner) }
let(:key_id) { key.identifier } let(:key_id) { key.identifier }
it "fetches the correct project" do it "fetches the correct project" do
......
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