BigW Consortium Gitlab

Commit 80fb38de by Vincent Bonmalais

Remove backward compatibility of factories.

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