From 80fb38de7abdfacbf5ad2e0150b934c1392721f0 Mon Sep 17 00:00:00 2001 From: Vincent Bonmalais Date: Tue, 6 Nov 2012 14:31:55 +1100 Subject: [PATCH] Remove backward compatibility of factories. --- features/steps/dashboard/dashboard.rb | 8 ++-- features/steps/dashboard/dashboard_search.rb | 2 +- features/steps/group/group.rb | 6 +-- features/steps/profile/profile.rb | 2 +- features/steps/profile/profile_ssh_keys.rb | 2 +- features/steps/project/project_hooks.rb | 2 +- features/steps/project/project_issues.rb | 26 ++++++------ features/steps/project/project_labels.rb | 2 +- .../steps/project/project_merge_requests.rb | 18 ++++----- features/steps/project/project_milestones.rb | 4 +- .../steps/project/project_team_management.rb | 6 +-- features/steps/shared/project.rb | 2 +- spec/factories.rb | 18 --------- spec/mailers/notify_spec.rb | 40 +++++++++---------- spec/models/event_spec.rb | 2 +- spec/models/issue_spec.rb | 8 ++-- spec/models/key_spec.rb | 4 +- spec/models/merge_request_spec.rb | 14 +++---- spec/models/milestone_spec.rb | 4 +- spec/models/note_spec.rb | 36 ++++++++--------- spec/models/project_hooks_spec.rb | 16 ++++---- spec/models/project_security_spec.rb | 6 +-- spec/models/project_spec.rb | 22 +++++----- spec/models/system_hook_spec.rb | 18 ++++----- spec/models/user_spec.rb | 2 +- spec/models/web_hook_spec.rb | 4 +- spec/observers/activity_observer_spec.rb | 18 ++++----- spec/observers/issue_observer_spec.rb | 4 +- spec/observers/merge_request_observer_spec.rb | 4 +- spec/observers/note_observer_spec.rb | 2 +- spec/observers/user_observer_spec.rb | 2 +- spec/observers/users_project_observer_spec.rb | 14 +++---- spec/requests/admin/admin_hooks_spec.rb | 8 ++-- spec/requests/admin/admin_projects_spec.rb | 8 ++-- spec/requests/admin/admin_users_spec.rb | 10 ++--- spec/requests/api/issues_spec.rb | 6 +-- spec/requests/api/merge_requests_spec.rb | 16 ++++---- spec/requests/api/milestones_spec.rb | 6 +-- spec/requests/api/projects_spec.rb | 18 ++++----- spec/requests/api/session_spec.rb | 2 +- spec/requests/api/users_spec.rb | 12 +++--- spec/requests/atom/dashboard_issues_spec.rb | 10 ++--- spec/requests/atom/dashboard_spec.rb | 2 +- spec/requests/atom/issues_spec.rb | 6 +-- .../requests/gitlab_flavored_markdown_spec.rb | 38 +++++++++--------- spec/requests/issues_spec.rb | 34 ++++++++-------- spec/requests/projects_deploy_keys_spec.rb | 6 +-- spec/requests/projects_spec.rb | 10 ++--- spec/requests/search_spec.rb | 4 +- spec/requests/security/profile_access_spec.rb | 2 +- spec/requests/snippets_spec.rb | 14 +++---- spec/support/login_helpers.rb | 2 +- spec/support/matchers.rb | 4 +- spec/workers/post_receive_spec.rb | 4 +- 54 files changed, 261 insertions(+), 279 deletions(-) diff --git a/features/steps/dashboard/dashboard.rb b/features/steps/dashboard/dashboard.rb index 008c1451..99c48738 100644 --- a/features/steps/dashboard/dashboard.rb +++ b/features/steps/dashboard/dashboard.rb @@ -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 diff --git a/features/steps/dashboard/dashboard_search.rb b/features/steps/dashboard/dashboard_search.rb index 53d74bf3..a34c14d0 100644 --- a/features/steps/dashboard/dashboard_search.rb +++ b/features/steps/dashboard/dashboard_search.rb @@ -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 diff --git a/features/steps/group/group.rb b/features/steps/group/group.rb index 51581a1e..4de260ec 100644 --- a/features/steps/group/group.rb +++ b/features/steps/group/group.rb @@ -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 diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb index efab1010..151182f6 100644 --- a/features/steps/profile/profile.rb +++ b/features/steps/profile/profile.rb @@ -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 diff --git a/features/steps/profile/profile_ssh_keys.rb b/features/steps/profile/profile_ssh_keys.rb index 535c3862..8ae1fa91 100644 --- a/features/steps/profile/profile_ssh_keys.rb +++ b/features/steps/profile/profile_ssh_keys.rb @@ -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 diff --git a/features/steps/project/project_hooks.rb b/features/steps/project/project_hooks.rb index 1786fe5b..36555fb8 100644 --- a/features/steps/project/project_hooks.rb +++ b/features/steps/project/project_hooks.rb @@ -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 diff --git a/features/steps/project/project_issues.rb b/features/steps/project/project_issues.rb index 64af2449..a9a33650 100644 --- a/features/steps/project/project_issues.rb +++ b/features/steps/project/project_issues.rb @@ -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 diff --git a/features/steps/project/project_labels.rb b/features/steps/project/project_labels.rb index 1a347bf3..915190f3 100644 --- a/features/steps/project/project_labels.rb +++ b/features/steps/project/project_labels.rb @@ -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 diff --git a/features/steps/project/project_merge_requests.rb b/features/steps/project/project_merge_requests.rb index 80e83906..d153ad28 100644 --- a/features/steps/project/project_merge_requests.rb +++ b/features/steps/project/project_merge_requests.rb @@ -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 diff --git a/features/steps/project/project_milestones.rb b/features/steps/project/project_milestones.rb index 4d689c95..1c9ad6da 100644 --- a/features/steps/project/project_milestones.rb +++ b/features/steps/project/project_milestones.rb @@ -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 diff --git a/features/steps/project/project_team_management.rb b/features/steps/project/project_team_management.rb index 5c3a9b31..6bde0b64 100644 --- a/features/steps/project/project_team_management.rb +++ b/features/steps/project/project_team_management.rb @@ -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 diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index ae871d63..dfc8ce9d 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -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 diff --git a/spec/factories.rb b/spec/factories.rb index 0258f892..7b2a2efa 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,21 +1,3 @@ -# 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 diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 874864a3..b6b1769f 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -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) } diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 77b49246..d68ebb86 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -32,7 +32,7 @@ describe Event do describe "Push event" do before do - project = Factory :project + project = create(:project) @user = project.owner data = { diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 7c98b9ea..4e999aad 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -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 diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb index d3231af8..80dfff08 100644 --- a/spec/models/key_spec.rb +++ b/spec/models/key_spec.rb @@ -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 diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index be40c561..3267f6f6 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -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 diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 1aba20c6..0e5cf7dd 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -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 diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 514b6202..d7390537 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -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 diff --git a/spec/models/project_hooks_spec.rb b/spec/models/project_hooks_spec.rb index 129e3d61..ee441ec4 100644 --- a/spec/models/project_hooks_spec.rb +++ b/spec/models/project_hooks_spec.rb @@ -1,15 +1,15 @@ 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 diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb index baf6d4b6..60f8d45c 100644 --- a/spec/models/project_security_spec.rb +++ b/spec/models/project_security_spec.rb @@ -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 diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 6fe46446..1cf4f586 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -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 diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb index b5d338a8..5f923911 100644 --- a/spec/models/system_hook_spec.rb +++ b/spec/models/system_hook_spec.rb @@ -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 it "user_create hook" do with_resque do - Factory :user + create(:user) end WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once end it "user_destroy hook" do - user = Factory :user + user = create(:user) with_resque do user.destroy end @@ -52,8 +52,8 @@ describe SystemHook do end it "project_create hook" do - user = Factory :user - project = Factory :project + user = create(:user) + project = create(:project) with_resque do project.users << user end @@ -61,8 +61,8 @@ describe SystemHook do end it "project_destroy hook" do - user = Factory :user - project = Factory :project + user = create(:user) + project = create(:project) project.users << user with_resque do project.users_projects.clear diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5f41fb05..b9654d70 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -108,7 +108,7 @@ describe User do describe 'authentication token' do it "should have authentication token" do - user = Factory(:user) + user = create(:user) user.authentication_token.should_not be_blank end end diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb index d71fec81..8f8decb8 100644 --- a/spec/models/web_hook_spec.rb +++ b/spec/models/web_hook_spec.rb @@ -39,8 +39,8 @@ describe ProjectHook do describe "execute" do before(:each) do - @project_hook = Factory :project_hook - @project = Factory :project + @project_hook = create(:project_hook) + @project = create(:project) @project.hooks << [@project_hook] @data = { before: 'oldrev', after: 'newrev', ref: 'ref'} diff --git a/spec/observers/activity_observer_spec.rb b/spec/observers/activity_observer_spec.rb index 0db4a998..0eec41f4 100644 --- a/spec/observers/activity_observer_spec.rb +++ b/spec/observers/activity_observer_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' describe ActivityObserver do - let(:project) { Factory :project } + let(:project) { create(:project) } def self.it_should_be_valid_event it { @event.should_not be_nil } it { @event.project.should == project } end - describe "Merge Request created" do + describe "Merge Request created" do before do MergeRequest.observers.enable :activity_observer do - @merge_request = Factory :merge_request, project: project + @merge_request = create(:merge_request, project: project) @event = Event.last end end @@ -21,10 +21,10 @@ describe ActivityObserver do it { @event.target.should == @merge_request } end - describe "Issue created" do + describe "Issue created" do before do Issue.observers.enable :activity_observer do - @issue = Factory :issue, project: project + @issue = create(:issue, project: project) @event = Event.last end end @@ -34,10 +34,10 @@ describe ActivityObserver do it { @event.target.should == @issue } end - #describe "Issue commented" do - #before do - #@issue = Factory :issue, project: project - #@note = Factory :note, noteable: @issue, project: project + #describe "Issue commented" do + #before do + #@issue = create(:issue, project: project) + #@note = create(:note, noteable: @issue, project: project) #@event = Event.last #end diff --git a/spec/observers/issue_observer_spec.rb b/spec/observers/issue_observer_spec.rb index b5943f2c..509c1d02 100644 --- a/spec/observers/issue_observer_spec.rb +++ b/spec/observers/issue_observer_spec.rb @@ -16,7 +16,7 @@ describe IssueObserver do subject.should_receive(:after_create) Issue.observers.enable :issue_observer do - Factory.create(:issue, project: Factory.create(:project)) + create(:issue, project: create(:project)) end end @@ -43,7 +43,7 @@ describe IssueObserver do end 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) Issue.observers.enable :issue_observer do diff --git a/spec/observers/merge_request_observer_spec.rb b/spec/observers/merge_request_observer_spec.rb index a9ba7927..6b15be96 100644 --- a/spec/observers/merge_request_observer_spec.rb +++ b/spec/observers/merge_request_observer_spec.rb @@ -16,7 +16,7 @@ describe MergeRequestObserver do subject.should_receive(:after_create) MergeRequest.observers.enable :merge_request_observer do - Factory.create(:merge_request, project: Factory.create(:project)) + create(:merge_request, project: create(:project)) end end @@ -43,7 +43,7 @@ describe MergeRequestObserver do end 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) MergeRequest.observers.enable :merge_request_observer do diff --git a/spec/observers/note_observer_spec.rb b/spec/observers/note_observer_spec.rb index 203a58a4..7dfa9f77 100644 --- a/spec/observers/note_observer_spec.rb +++ b/spec/observers/note_observer_spec.rb @@ -13,7 +13,7 @@ describe NoteObserver do subject.should_receive :after_create Note.observers.enable :note_observer do - Factory.create(:note) + create(:note) end end diff --git a/spec/observers/user_observer_spec.rb b/spec/observers/user_observer_spec.rb index 0420a250..08254f44 100644 --- a/spec/observers/user_observer_spec.rb +++ b/spec/observers/user_observer_spec.rb @@ -4,7 +4,7 @@ describe UserObserver do subject { UserObserver.instance } 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) User.observers.enable :user_observer do diff --git a/spec/observers/users_project_observer_spec.rb b/spec/observers/users_project_observer_spec.rb index a8e0834b..cbe42248 100644 --- a/spec/observers/users_project_observer_spec.rb +++ b/spec/observers/users_project_observer_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' describe UsersProjectObserver do - let(:user) { Factory.create :user } - let(:project) { Factory.create(:project, - code: "Fuu", - path: "Fuu" ) } - let(:users_project) { Factory.create(:users_project, - project: project, - user: user )} + let(:user) { create(:user) } + let(:project) { create(:project, + code: "Fuu", + path: "Fuu" ) } + let(:users_project) { create(:users_project, + project: project, + user: user )} subject { UsersProjectObserver.instance } describe "#after_commit" do diff --git a/spec/requests/admin/admin_hooks_spec.rb b/spec/requests/admin/admin_hooks_spec.rb index 2f026aab..3f35b2fd 100644 --- a/spec/requests/admin/admin_hooks_spec.rb +++ b/spec/requests/admin/admin_hooks_spec.rb @@ -2,12 +2,12 @@ require 'spec_helper' describe "Admin::Hooks" do before do - @project = Factory :project, - name: "LeGiT", - code: "LGT" + @project = create(:project, + name: "LeGiT", + code: "LGT") login_as :admin - @system_hook = Factory :system_hook + @system_hook = create(:system_hook) end diff --git a/spec/requests/admin/admin_projects_spec.rb b/spec/requests/admin/admin_projects_spec.rb index 61e66eec..43e39d7c 100644 --- a/spec/requests/admin/admin_projects_spec.rb +++ b/spec/requests/admin/admin_projects_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe "Admin::Projects" do before do - @project = Factory :project, - name: "LeGiT", - code: "LGT" + @project = create(:project, + name: "LeGiT", + code: "LGT") login_as :admin end @@ -104,7 +104,7 @@ describe "Admin::Projects" do describe "Add new team member" do before do - @new_user = Factory :user + @new_user = create(:user) visit admin_project_path(@project) end diff --git a/spec/requests/admin/admin_users_spec.rb b/spec/requests/admin/admin_users_spec.rb index 68358bf0..9f43f07a 100644 --- a/spec/requests/admin/admin_users_spec.rb +++ b/spec/requests/admin/admin_users_spec.rb @@ -76,7 +76,7 @@ describe "Admin::Users" do describe "GET /admin/users/:id/edit" do before do - @simple_user = Factory :user + @simple_user = create(:user) visit admin_users_path click_link "edit_user_#{@simple_user.id}" end @@ -107,13 +107,13 @@ describe "Admin::Users" do end end - describe "Add new project" do - before do - @new_project = Factory :project + describe "Add new project" do + before do + @new_project = create(:project) visit admin_user_path(@user) end - it "should create new user" do + it "should create new user" do select @new_project.name, from: "project_ids" expect { click_button "Add" }.to change { UsersProject.count }.by(1) page.should have_content @new_project.name diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 442e9c73..6ea7e9b5 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe Gitlab::API do include ApiHelpers - let(:user) { Factory :user } - let!(:project) { Factory :project, owner: user } - let!(:issue) { Factory :issue, author: user, assignee: user, project: project } + let(:user) { create(:user) } + let!(:project) { create(:project, owner: user) } + let!(:issue) { create(:issue, author: user, assignee: user, project: project) } before { project.add_access(user, :read) } describe "GET /issues" do diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index e1c7949f..e83f2467 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -1,11 +1,11 @@ require "spec_helper" -describe Gitlab::API do +describe Gitlab::API do include ApiHelpers - - let(:user) { Factory :user } - let!(:project) { Factory :project, owner: user } - let!(:merge_request) { Factory :merge_request, author: user, assignee: user, project: project, title: "Test" } + + let(:user) { create(:user ) } + let!(:project) { create(:project, owner: user) } + let!(:merge_request) { create(:merge_request, author: user, assignee: user, project: project, title: "Test") } before { project.add_access(user, :read) } describe "GET /projects/:id/merge_requests" do @@ -39,7 +39,7 @@ describe Gitlab::API do post api("/projects/#{project.code}/merge_requests", user), title: 'Test merge_request', source_branch: "stable", target_branch: "master", author: user response.status.should == 201 - json_response['title'].should == 'Test merge_request' + json_response['title'].should == 'Test merge_request' end end @@ -47,7 +47,7 @@ describe Gitlab::API do it "should return merge_request" do put api("/projects/#{project.code}/merge_request/#{merge_request.id}", user), title: "New title" response.status.should == 200 - json_response['title'].should == 'New title' + json_response['title'].should == 'New title' end end @@ -55,7 +55,7 @@ describe Gitlab::API do it "should return comment" do post api("/projects/#{project.code}/merge_request/#{merge_request.id}/comments", user), note: "My comment" response.status.should == 201 - json_response['note'].should == 'My comment' + json_response['note'].should == 'My comment' end end diff --git a/spec/requests/api/milestones_spec.rb b/spec/requests/api/milestones_spec.rb index cf5f65f0..860825ab 100644 --- a/spec/requests/api/milestones_spec.rb +++ b/spec/requests/api/milestones_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe Gitlab::API do include ApiHelpers - let(:user) { Factory :user } - let!(:project) { Factory :project, owner: user } - let!(:milestone) { Factory :milestone, project: project } + let(:user) { create(:user) } + let!(:project) { create(:project, owner: user) } + let!(:milestone) { create(:milestone, project: project) } before { project.add_access(user, :read) } diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 5f9a587d..d24ce43d 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' describe Gitlab::API do include ApiHelpers - let(:user) { Factory :user } - let(:user2) { Factory.create(:user) } - let(:user3) { Factory.create(:user) } - let!(:hook) { Factory :project_hook, project: project, url: "http://example.com" } - let!(:project) { Factory :project, owner: user } - let!(:snippet) { Factory :snippet, author: user, project: project, title: 'example' } - let!(:users_project) { Factory :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(:user) { create(:user) } + let(:user2) { create(:user) } + let(:user3) { create(:user) } + let!(:hook) { create(:project_hook, project: project, url: "http://example.com") } + let!(:project) { create(:project, owner: user ) } + let!(:snippet) { create(:snippet, author: user, project: project, title: 'example') } + let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } + let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } before { project.add_access(user, :read) } describe "GET /projects" do @@ -52,7 +52,7 @@ describe Gitlab::API do end it "should assign attributes to project" do - project = Factory.attributes(:project, { + project = attributes_for(:project, { path: 'path', code: 'code', description: Faker::Lorem.sentence, diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb index f251f392..afae8be8 100644 --- a/spec/requests/api/session_spec.rb +++ b/spec/requests/api/session_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe Gitlab::API do include ApiHelpers - let(:user) { Factory :user } + let(:user) { create(:user) } describe "POST /session" do context "when valid password" do diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 4c2e6ada..4cfb4884 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -3,9 +3,9 @@ require 'spec_helper' describe Gitlab::API do include ApiHelpers - let(:user) { Factory :user } - let(:admin) { Factory :admin } - let(:key) { Factory :key, user: user } + let(:user) { create(:user) } + let(:admin) { create(:admin) } + let(:key) { create(:key, user: user) } describe "GET /users" do context "when unauthenticated" do @@ -43,12 +43,12 @@ describe Gitlab::API do it "should create user" do 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) end 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 end end @@ -103,7 +103,7 @@ describe Gitlab::API do end it "should create ssh key" do - key_attrs = Factory.attributes :key + key_attrs = attributes_for :key expect { post api("/user/keys", user), key_attrs }.to change{ user.keys.count }.by(1) diff --git a/spec/requests/atom/dashboard_issues_spec.rb b/spec/requests/atom/dashboard_issues_spec.rb index 8d1111fc..8ce64cd4 100644 --- a/spec/requests/atom/dashboard_issues_spec.rb +++ b/spec/requests/atom/dashboard_issues_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' describe "Dashboard Issues Feed" do describe "GET /issues" do - let!(:user) { Factory :user } - let!(:project1) { Factory :project } - let!(:project2) { Factory :project } - let!(:issue1) { Factory :issue, author: user, assignee: user, project: project1 } - let!(:issue2) { Factory :issue, author: user, assignee: user, project: project2 } + let!(:user) { create(:user) } + let!(:project1) { create(:project) } + let!(:project2) { create(:project) } + let!(:issue1) { create(:issue, author: user, assignee: user, project: project1) } + let!(:issue2) { create(:issue, author: user, assignee: user, project: project2) } describe "atom feed" do it "should render atom feed via private token" do diff --git a/spec/requests/atom/dashboard_spec.rb b/spec/requests/atom/dashboard_spec.rb index c160d24a..6257ad5c 100644 --- a/spec/requests/atom/dashboard_spec.rb +++ b/spec/requests/atom/dashboard_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe "Dashboard Feed" do describe "GET /" do - let!(:user) { Factory :user } + let!(:user) { create(:user) } context "projects atom feed via private token" do it "should render projects atom feed" do diff --git a/spec/requests/atom/issues_spec.rb b/spec/requests/atom/issues_spec.rb index c8671979..29f88f3f 100644 --- a/spec/requests/atom/issues_spec.rb +++ b/spec/requests/atom/issues_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' describe "Issues Feed" do describe "GET /issues" do - let!(:user) { Factory :user } - let!(:project) { Factory :project, owner: user } - let!(:issue) { Factory :issue, author: user, project: project } + let!(:user) { create(:user) } + let!(:project) { create(:project, owner: user) } + let!(:issue) { create(:issue, author: user, project: project) } before { project.add_access(user, :read, :write) } diff --git a/spec/requests/gitlab_flavored_markdown_spec.rb b/spec/requests/gitlab_flavored_markdown_spec.rb index 014f99eb..aedd435e 100644 --- a/spec/requests/gitlab_flavored_markdown_spec.rb +++ b/spec/requests/gitlab_flavored_markdown_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe "Gitlab Flavored Markdown" do - let(:project) { Factory :project } - let(:issue) { Factory :issue, project: project } - let(:merge_request) { Factory :merge_request, project: project } + let(:project) { create(:project) } + let(:issue) { create(:issue, project: project) } + let(:merge_request) { create(:merge_request, project: project) } let(:fred) do - u = Factory :user, name: "fred" + u = create(:user, name: "fred") project.users << u u end @@ -84,16 +84,16 @@ describe "Gitlab Flavored Markdown" do describe "for issues" do before do - @other_issue = Factory :issue, + @other_issue = create(:issue, + author: @user, + assignee: @user, + project: project) + @issue = create(:issue, author: @user, assignee: @user, - project: project - @issue = Factory :issue, - author: @user, - assignee: @user, - project: project, - title: "fix ##{@other_issue.id}", - description: "ask @#{fred.name} for details" + project: project, + title: "fix ##{@other_issue.id}", + description: "ask @#{fred.name} for details") end it "should render subject in issues#index" do @@ -118,9 +118,9 @@ describe "Gitlab Flavored Markdown" do describe "for merge requests" do before do - @merge_request = Factory :merge_request, - project: project, - title: "fix ##{issue.id}" + @merge_request = create(:merge_request, + project: project, + title: "fix ##{issue.id}") end it "should render title in merge_requests#index" do @@ -139,10 +139,10 @@ describe "Gitlab Flavored Markdown" do describe "for milestones" do before do - @milestone = Factory :milestone, - project: project, - title: "fix ##{issue.id}", - description: "ask @#{fred.name} for details" + @milestone = create(:milestone, + project: project, + title: "fix ##{issue.id}", + description: "ask @#{fred.name} for details") end it "should render title in milestones#index" do diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb index 15ee5d17..c95409d3 100644 --- a/spec/requests/issues_spec.rb +++ b/spec/requests/issues_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe "Issues" do - let(:project) { Factory :project } + let(:project) { create(:project) } before do login_as :user - @user2 = Factory :user + @user2 = create(:user) project.add_access(@user, :read, :write) project.add_access(@user2, :read, :write) @@ -13,10 +13,10 @@ describe "Issues" do describe "Edit issue", js: true do before do - @issue = Factory :issue, - author: @user, - assignee: @user, - project: project + @issue = create(:issue, + author: @user, + assignee: @user, + project: project) visit project_issues_path(project) click_link "Edit" end @@ -46,11 +46,11 @@ describe "Issues" do describe "Search issue", js: true do before do ['foobar', 'foobar2', 'gitlab'].each do |title| - @issue = Factory :issue, - author: @user, - assignee: @user, - project: project, - title: title + @issue = create(:issue, + author: @user, + assignee: @user, + project: project, + title: title) @issue.save end end @@ -93,15 +93,15 @@ describe "Issues" do describe "Filter issue" do before do ['foobar', 'barbaz', 'gitlab'].each do |title| - @issue = Factory :issue, - author: @user, - assignee: @user, - project: project, - title: title + @issue = create(:issue, + author: @user, + assignee: @user, + project: project, + title: title) end @issue = Issue.first - @issue.milestone = Factory(:milestone, project: project) + @issue.milestone = create(:milestone, project: project) @issue.assignee = nil @issue.save end diff --git a/spec/requests/projects_deploy_keys_spec.rb b/spec/requests/projects_deploy_keys_spec.rb index df1be79d..35323f55 100644 --- a/spec/requests/projects_deploy_keys_spec.rb +++ b/spec/requests/projects_deploy_keys_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe "Projects", "DeployKeys" do - let(:project) { Factory :project } + let(:project) { create(:project) } before do login_as :user @@ -10,7 +10,7 @@ describe "Projects", "DeployKeys" do describe "GET /keys" do before do - @key = Factory :key, project: project + @key = create(:key, project: project) visit project_deploy_keys_path(project) end @@ -57,7 +57,7 @@ describe "Projects", "DeployKeys" do describe "Show page" do before do - @key = Factory :key, project: project + @key = create(:key, project: project) visit project_deploy_key_path(project, @key) end diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index 92e89a16..c44bea89 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -6,7 +6,7 @@ describe "Projects" do describe 'GET /project/new' do it "should work autocomplete", :js => true do visit new_project_path - + fill_in 'project_name', with: 'Awesome' find("#project_path").value.should == 'awesome' find("#project_code").value.should == 'awesome' @@ -15,7 +15,7 @@ describe "Projects" do describe "GET /projects/show" do before do - @project = Factory :project, owner: @user + @project = create(:project, owner: @user) @project.add_access(@user, :read) visit project_path(@project) @@ -28,7 +28,7 @@ describe "Projects" do describe "GET /projects/:id/edit" do before do - @project = Factory :project + @project = create(:project) @project.add_access(@user, :admin, :read) visit edit_project_path(@project) @@ -47,7 +47,7 @@ describe "Projects" do describe "PUT /projects/:id" do before do - @project = Factory :project, owner: @user + @project = create(:project, owner: @user) @project.add_access(@user, :admin, :read) visit edit_project_path(@project) @@ -69,7 +69,7 @@ describe "Projects" do describe "DELETE /projects/:id" do before do - @project = Factory :project + @project = create(:project) @project.add_access(@user, :read, :admin) visit edit_project_path(@project) end diff --git a/spec/requests/search_spec.rb b/spec/requests/search_spec.rb index 537c4d0c..17cc0d39 100644 --- a/spec/requests/search_spec.rb +++ b/spec/requests/search_spec.rb @@ -3,14 +3,14 @@ require 'spec_helper' describe "Search" do before do login_as :user - @project = Factory :project + @project = create(:project) @project.add_access(@user, :read) visit search_path fill_in "search", with: @project.name[0..3] click_button "Search" end - it "should show project in search results" do + it "should show project in search results" do page.should have_content @project.name end end diff --git a/spec/requests/security/profile_access_spec.rb b/spec/requests/security/profile_access_spec.rb index 69c1c29c..8562b8e7 100644 --- a/spec/requests/security/profile_access_spec.rb +++ b/spec/requests/security/profile_access_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe "Users Security" do describe "Project" do before do - @u1 = Factory :user + @u1 = create(:user) end describe "GET /login" do diff --git a/spec/requests/snippets_spec.rb b/spec/requests/snippets_spec.rb index 6b993660..9ef217ba 100644 --- a/spec/requests/snippets_spec.rb +++ b/spec/requests/snippets_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe "Snippets" do - let(:project) { Factory :project } + let(:project) { create(:project) } before do login_as :user @@ -10,9 +10,9 @@ describe "Snippets" do describe "GET /snippets" do before do - @snippet = Factory :snippet, - author: @user, - project: project + @snippet = create(:snippet, + author: @user, + project: project) visit project_snippets_path(project) end @@ -68,9 +68,9 @@ describe "Snippets" do describe "Edit snippet" do before do - @snippet = Factory :snippet, - author: @user, - project: project + @snippet = create(:snippet, + author: @user, + project: project) visit project_snippet_path(project, @snippet) click_link "Edit" end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 769034e2..4579c971 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -3,7 +3,7 @@ module LoginHelpers # # role - User role (e.g., :admin, :user) def login_as(role) - @user = Factory(role) + @user = create(role) login_with(@user) end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 809453c4..29d16ecb 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -59,9 +59,9 @@ module UrlAccess def emulate_user(user) user = case user - when :user then Factory(:user) + when :user then create(:user) when :visitor then nil - when :admin then Factory(:admin) + when :admin then create(:admin) else user end login_with(user) if user diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb index 6f4bcca2..22e3e0d0 100644 --- a/spec/workers/post_receive_spec.rb +++ b/spec/workers/post_receive_spec.rb @@ -9,8 +9,8 @@ describe PostReceive do end context "web hook" do - let(:project) { Factory.create(:project) } - let(:key) { Factory.create(:key, user: project.owner) } + let(:project) { create(:project) } + let(:key) { create(:key, user: project.owner) } let(:key_id) { key.identifier } it "fetches the correct project" do