Commit c227aa44 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Make changes to tests

* project_with_code -> project
* project -> ermpty_project
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 4b3afe23
...@@ -66,7 +66,7 @@ class DashboardIssues < Spinach::FeatureSteps ...@@ -66,7 +66,7 @@ class DashboardIssues < Spinach::FeatureSteps
def project def project
@project ||= begin @project ||= begin
project =create :project_with_code project =create :project
project.team << [current_user, :master] project.team << [current_user, :master]
project project
end end
......
...@@ -66,7 +66,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps ...@@ -66,7 +66,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps
def project def project
@project ||= begin @project ||= begin
project =create :project_with_code project =create :project
project.team << [current_user, :master] project.team << [current_user, :master]
project project
end end
......
...@@ -12,7 +12,7 @@ class ForkProject < Spinach::FeatureSteps ...@@ -12,7 +12,7 @@ class ForkProject < Spinach::FeatureSteps
step 'I am a member of project "Shop"' do step 'I am a member of project "Shop"' do
@project = Project.find_by_name "Shop" @project = Project.find_by_name "Shop"
@project ||= create(:project_with_code, name: "Shop", group: create(:group)) @project ||= create(:project, name: "Shop", group: create(:group))
@project.team << [@user, :reporter] @project.team << [@user, :reporter]
end end
...@@ -26,7 +26,7 @@ class ForkProject < Spinach::FeatureSteps ...@@ -26,7 +26,7 @@ class ForkProject < Spinach::FeatureSteps
current_user.namespace ||= create(:namespace) current_user.namespace ||= create(:namespace)
current_user.namespace.should_not be_nil current_user.namespace.should_not be_nil
current_user.namespace.path.should_not be_nil current_user.namespace.path.should_not be_nil
@my_project = create(:project_with_code, name: "Shop", namespace: current_user.namespace) @my_project = create(:project, name: "Shop", namespace: current_user.namespace)
end end
step 'I should see a "Name has already been taken" warning' do step 'I should see a "Name has already been taken" warning' do
......
...@@ -7,7 +7,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -7,7 +7,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
step 'I am a member of project "Shop"' do step 'I am a member of project "Shop"' do
@project = Project.find_by_name "Shop" @project = Project.find_by_name "Shop"
@project ||= create(:project_with_code, name: "Shop") @project ||= create(:project, name: "Shop")
@project.team << [@user, :reporter] @project.team << [@user, :reporter]
end end
...@@ -15,7 +15,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -15,7 +15,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
@forking_user = @user @forking_user = @user
forked_project_link = build(:forked_project_link) forked_project_link = build(:forked_project_link)
@forked_project = Project.find_by_name "Forked Shop" @forked_project = Project.find_by_name "Forked Shop"
@forked_project ||= create(:source_project_with_code, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace) @forked_project ||= create(:source_project, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace)
forked_project_link.forked_from_project = @project forked_project_link.forked_from_project = @project
forked_project_link.forked_to_project = @forked_project forked_project_link.forked_to_project = @forked_project
......
...@@ -5,7 +5,7 @@ class ProjectIssueTracker < Spinach::FeatureSteps ...@@ -5,7 +5,7 @@ class ProjectIssueTracker < Spinach::FeatureSteps
step 'project "Shop" has issues enabled' do step 'project "Shop" has issues enabled' do
@project = Project.find_by_name "Shop" @project = Project.find_by_name "Shop"
@project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace) @project ||= create(:project, name: "Shop", namespace: @user.namespace)
@project.issues_enabled = true @project.issues_enabled = true
end end
......
...@@ -4,7 +4,7 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps ...@@ -4,7 +4,7 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps
And 'I own project "Delta"' do And 'I own project "Delta"' do
@project = Project.find_by_name "Delta" @project = Project.find_by_name "Delta"
@project ||= create(:project_with_code, name: "Delta", namespace: @user.namespace) @project ||= create(:project, name: "Delta", namespace: @user.namespace)
@project.team << [@user, :master] @project.team << [@user, :master]
end end
......
...@@ -4,7 +4,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps ...@@ -4,7 +4,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
include SharedProject include SharedProject
step 'public project "Community"' do step 'public project "Community"' do
create :project_with_code, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC create :project, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC
end end
step 'private project "Enterprise"' do step 'private project "Enterprise"' do
......
...@@ -25,7 +25,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -25,7 +25,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'public project "Community"' do step 'public project "Community"' do
create :project_with_code, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC create :project, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC
end end
step 'public empty project "Empty Public Project"' do step 'public empty project "Empty Public Project"' do
...@@ -76,7 +76,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -76,7 +76,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'internal project "Internal"' do step 'internal project "Internal"' do
create :project_with_code, name: 'Internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL create :project, name: 'Internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL
end end
step 'I should see project "Internal"' do step 'I should see project "Internal"' do
......
...@@ -3,21 +3,21 @@ module SharedProject ...@@ -3,21 +3,21 @@ module SharedProject
# Create a project without caring about what it's called # Create a project without caring about what it's called
And "I own a project" do And "I own a project" do
@project = create(:project_with_code, namespace: @user.namespace) @project = create(:project, namespace: @user.namespace)
@project.team << [@user, :master] @project.team << [@user, :master]
end end
# Create a specific project called "Shop" # Create a specific project called "Shop"
And 'I own project "Shop"' do And 'I own project "Shop"' do
@project = Project.find_by_name "Shop" @project = Project.find_by_name "Shop"
@project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace) @project ||= create(:project, name: "Shop", namespace: @user.namespace)
@project.team << [@user, :master] @project.team << [@user, :master]
end end
# Create another specific project called "Forum" # Create another specific project called "Forum"
And 'I own project "Forum"' do And 'I own project "Forum"' do
@project = Project.find_by_name "Forum" @project = Project.find_by_name "Forum"
@project ||= create(:project_with_code, name: "Forum", namespace: @user.namespace, path: 'forum_project') @project ||= create(:project, name: "Forum", namespace: @user.namespace, path: 'forum_project')
@project.team << [@user, :master] @project.team << [@user, :master]
end end
......
require 'spec_helper' require 'spec_helper'
describe Projects::BlobController do describe Projects::BlobController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::CommitController do describe Projects::CommitController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:commit) { project.repository.commit("master") } let(:commit) { project.repository.commit("master") }
......
require 'spec_helper' require 'spec_helper'
describe Projects::CommitsController do describe Projects::CommitsController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::MergeRequestsController do describe Projects::MergeRequestsController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project, target_branch: "stable", source_branch: "master") } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project, target_branch: "stable", source_branch: "master") }
......
require 'spec_helper' require 'spec_helper'
describe Projects::TreeController do describe Projects::TreeController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -27,43 +27,16 @@ FactoryGirl.define do ...@@ -27,43 +27,16 @@ FactoryGirl.define do
factory :admin, traits: [:admin] factory :admin, traits: [:admin]
end end
factory :project do factory :empty_project, class: 'Project' do
sequence(:name) { |n| "project#{n}" } sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
namespace namespace
creator creator
trait :source do
sequence(:name) { |n| "source project#{n}" }
end
trait :target do
sequence(:name) { |n| "target project#{n}" }
end
factory :source_project, traits: [:source]
factory :target_project, traits: [:target]
end end
factory :project, parent: :empty_project do
factory :redmine_project, parent: :project do
issues_tracker { "redmine" }
issues_tracker_id { "project_name_in_redmine" }
end
factory :project_with_code, parent: :project do
path { 'gitlabhq' } path { 'gitlabhq' }
trait :source_path do
path { 'source_gitlabhq' }
end
trait :target_path do
path { 'target_gitlabhq' }
end
factory :source_project_with_code, traits: [:source, :source_path]
factory :target_project_with_code, traits: [:target, :target_path]
after :create do |project| after :create do |project|
TestEnv.clear_repo_dir(project.namespace, project.path) TestEnv.clear_repo_dir(project.namespace, project.path)
TestEnv.reset_satellite_dir TestEnv.reset_satellite_dir
...@@ -71,6 +44,11 @@ FactoryGirl.define do ...@@ -71,6 +44,11 @@ FactoryGirl.define do
end end
end end
factory :redmine_project, parent: :project do
issues_tracker { "redmine" }
issues_tracker_id { "project_name_in_redmine" }
end
factory :group do factory :group do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
...@@ -109,25 +87,12 @@ FactoryGirl.define do ...@@ -109,25 +87,12 @@ FactoryGirl.define do
factory :merge_request do factory :merge_request do
title title
author author
source_project factory: :source_project_with_code source_project factory: :project
target_project factory: :target_project_with_code target_project { source_project }
source_branch "master" source_branch "master"
target_branch "stable" target_branch "stable"
# pick 3 commits "at random" (from bcf03b5d~3 to bcf03b5d)
trait :with_diffs do trait :with_diffs do
target_branch "master" # pretend bcf03b5d~3
source_branch "stable" # pretend bcf03b5d
st_commits do
[
source_project.repository.commit('bcf03b5d').to_hash,
source_project.repository.commit('bcf03b5d~1').to_hash,
source_project.repository.commit('bcf03b5d~2').to_hash
]
end
st_diffs do
source_project.repo.diff("bcf03b5d~3", "bcf03b5d")
end
end end
trait :closed do trait :closed do
...@@ -156,7 +121,7 @@ FactoryGirl.define do ...@@ -156,7 +121,7 @@ FactoryGirl.define do
factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment] factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment]
trait :on_commit do trait :on_commit do
project factory: :project_with_code project factory: :project
commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
noteable_type "Commit" noteable_type "Commit"
end end
...@@ -166,7 +131,7 @@ FactoryGirl.define do ...@@ -166,7 +131,7 @@ FactoryGirl.define do
end end
trait :on_merge_request do trait :on_merge_request do
project factory: :project_with_code project factory: :project
noteable_id 1 noteable_id 1
noteable_type "MergeRequest" noteable_type "MergeRequest"
end end
......
require 'spec_helper' require 'spec_helper'
describe "GitLab Flavored Markdown" do describe "GitLab Flavored Markdown" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:fred) do let(:fred) do
......
require 'spec_helper' require 'spec_helper'
describe "On a merge request", js: true do describe "On a merge request", js: true do
let!(:project) { create(:project_with_code) } let!(:project) { create(:project) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:note) { create(:note_on_merge_request_with_attachment, project: project) } let!(:note) { create(:note_on_merge_request_with_attachment, project: project) }
...@@ -135,7 +135,7 @@ describe "On a merge request", js: true do ...@@ -135,7 +135,7 @@ describe "On a merge request", js: true do
end end
describe "On a merge request diff", js: true, focus: true do describe "On a merge request diff", js: true, focus: true do
let!(:project) { create(:source_project_with_code) } let!(:project) { create(:source_project) }
let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
before do before do
...@@ -185,7 +185,7 @@ describe "On a merge request diff", js: true, focus: true do ...@@ -185,7 +185,7 @@ describe "On a merge request diff", js: true, focus: true do
end end
describe "with muliple note forms" do describe "with muliple note forms" do
let!(:project) { create(:source_project_with_code) } let!(:project) { create(:source_project) }
let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe "Internal Project Access" do describe "Internal Project Access" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe "Private Project Access" do describe "Private Project Access" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe "Public Project Access" do describe "Public Project Access" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
......
...@@ -4,7 +4,7 @@ describe GitlabMarkdownHelper do ...@@ -4,7 +4,7 @@ describe GitlabMarkdownHelper do
include ApplicationHelper include ApplicationHelper
include IssuesHelper include IssuesHelper
let!(:project) { create(:project_with_code) } let!(:project) { create(:project) }
let(:user) { create(:user, username: 'gfm') } let(:user) { create(:user, username: 'gfm') }
let(:commit) { project.repository.commit } let(:commit) { project.repository.commit }
......
...@@ -43,7 +43,7 @@ describe SearchHelper do ...@@ -43,7 +43,7 @@ describe SearchHelper do
end end
context "with a current project" do context "with a current project" do
before { @project = create(:project_with_code) } before { @project = create(:project) }
it "includes project-specific sections" do it "includes project-specific sections" do
search_autocomplete_opts("Files").size.should == 1 search_autocomplete_opts("Files").size.should == 1
......
...@@ -43,7 +43,7 @@ describe Gitlab::ReferenceExtractor do ...@@ -43,7 +43,7 @@ describe Gitlab::ReferenceExtractor do
end end
context 'with a project' do context 'with a project' do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
it 'accesses valid user objects on the project team' do it 'accesses valid user objects on the project team' do
@u_foo = create(:user, username: 'foo') @u_foo = create(:user, username: 'foo')
......
require 'spec_helper' require 'spec_helper'
describe 'Gitlab::Satellite::Action' do describe 'Gitlab::Satellite::Action' do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
describe '#prepare_satellite!' do describe '#prepare_satellite!' do
......
...@@ -12,7 +12,7 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -12,7 +12,7 @@ describe 'Gitlab::Satellite::MergeAction' do
@close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633'] @close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633']
end end
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:merge_request_fork) { create(:merge_request) } let(:merge_request_fork) { create(:merge_request) }
......
...@@ -5,7 +5,7 @@ describe Notify do ...@@ -5,7 +5,7 @@ describe Notify do
include EmailSpec::Matchers include EmailSpec::Matchers
let(:recipient) { create(:user, email: 'recipient@example.com') } let(:recipient) { create(:user, email: 'recipient@example.com') }
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
shared_examples 'a multiple recipients email' do shared_examples 'a multiple recipients email' do
it 'is sent to the given recipient' do it 'is sent to the given recipient' do
......
...@@ -25,7 +25,7 @@ describe AssemblaService do ...@@ -25,7 +25,7 @@ describe AssemblaService do
describe "Execute" do describe "Execute" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
@assembla_service = AssemblaService.new @assembla_service = AssemblaService.new
......
require 'spec_helper' require 'spec_helper'
describe Commit do describe Commit do
let(:project) { create :project_with_code } let(:project) { create :project }
let(:commit) { project.repository.commit } let(:commit) { project.repository.commit }
describe '#title' do describe '#title' do
......
...@@ -25,7 +25,7 @@ describe FlowdockService do ...@@ -25,7 +25,7 @@ describe FlowdockService do
describe "Execute" do describe "Execute" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
@flowdock_service = FlowdockService.new @flowdock_service = FlowdockService.new
......
...@@ -206,7 +206,7 @@ describe Note do ...@@ -206,7 +206,7 @@ describe Note do
end end
describe '#create_cross_reference_note' do describe '#create_cross_reference_note' do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:author) { create(:user) } let(:author) { create(:user) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:mergereq) { create(:merge_request, target_project: project) } let(:mergereq) { create(:merge_request, target_project: project) }
......
...@@ -128,7 +128,7 @@ describe Project do ...@@ -128,7 +128,7 @@ describe Project do
end end
describe :update_merge_requests do describe :update_merge_requests do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
@merge_request = create(:merge_request, source_project: project, target_project: project) @merge_request = create(:merge_request, source_project: project, target_project: project)
...@@ -237,7 +237,7 @@ describe Project do ...@@ -237,7 +237,7 @@ describe Project do
end end
describe :open_branches do describe :open_branches do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
project.protected_branches.create(name: 'master') project.protected_branches.create(name: 'master')
......
...@@ -49,7 +49,7 @@ describe Service do ...@@ -49,7 +49,7 @@ describe Service do
end end
describe "With commits" do describe "With commits" do
let (:project) { create :project_with_code } let (:project) { create :project }
before do before do
@service.stub( @service.stub(
......
...@@ -4,16 +4,17 @@ describe MergeRequestObserver do ...@@ -4,16 +4,17 @@ describe MergeRequestObserver do
let(:some_user) { create :user } let(:some_user) { create :user }
let(:assignee) { create :user } let(:assignee) { create :user }
let(:author) { create :user } let(:author) { create :user }
let(:project) { create :project }
let(:mr_mock) { double(:merge_request, id: 42, assignee: assignee, author: author).as_null_object } let(:mr_mock) { double(:merge_request, id: 42, assignee: assignee, author: author).as_null_object }
let(:assigned_mr) { create(:merge_request, assignee: assignee, author: author, target_project: create(:project)) } let(:assigned_mr) { create(:merge_request, assignee: assignee, author: author, source_project: project) }
let(:unassigned_mr) { create(:merge_request, author: author, target_project: create(:project)) } let(:unassigned_mr) { create(:merge_request, author: author, source_project: project) }
let(:closed_assigned_mr) { create(:closed_merge_request, assignee: assignee, author: author, target_project: create(:project)) } let(:closed_assigned_mr) { create(:closed_merge_request, assignee: assignee, author: author, source_project: project) }
let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, target_project: create(:project)) } let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, source_project: project) }
before { subject.stub(:current_user).and_return(some_user) } before { subject.stub(:current_user).and_return(some_user) }
before { subject.stub(notification: double('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
before { mr_mock.stub(:author_id) } before { mr_mock.stub(:author_id) }
before { mr_mock.stub(:target_project) } before { mr_mock.stub(:source_project) }
before { mr_mock.stub(:source_project) } before { mr_mock.stub(:source_project) }
before { mr_mock.stub(:project) } before { mr_mock.stub(:project) }
before { mr_mock.stub(:create_cross_references!).and_return(true) } before { mr_mock.stub(:create_cross_references!).and_return(true) }
...@@ -46,7 +47,7 @@ describe MergeRequestObserver do ...@@ -46,7 +47,7 @@ describe MergeRequestObserver do
end end
it 'is called when a merge request is changed' do it 'is called when a merge request is changed' do
changed = create(:merge_request, source_project: create(:project)) changed = create(:merge_request, source_project: project)
subject.should_receive(:after_update) subject.should_receive(:after_update)
MergeRequest.observers.enable :merge_request_observer do MergeRequest.observers.enable :merge_request_observer do
...@@ -81,13 +82,13 @@ describe MergeRequestObserver do ...@@ -81,13 +82,13 @@ describe MergeRequestObserver do
context '#after_close' do context '#after_close' do
context 'a status "closed"' do context 'a status "closed"' do
it 'note is created if the merge request is being closed' do it 'note is created if the merge request is being closed' do
Note.should_receive(:create_status_change_note).with(assigned_mr, assigned_mr.target_project, some_user, 'closed', nil) Note.should_receive(:create_status_change_note).with(assigned_mr, assigned_mr.source_project, some_user, 'closed', nil)
assigned_mr.close assigned_mr.close
end end
it 'notification is delivered only to author if the merge request is being closed' do it 'notification is delivered only to author if the merge request is being closed' do
Note.should_receive(:create_status_change_note).with(unassigned_mr, unassigned_mr.target_project, some_user, 'closed', nil) Note.should_receive(:create_status_change_note).with(unassigned_mr, unassigned_mr.source_project, some_user, 'closed', nil)
unassigned_mr.close unassigned_mr.close
end end
...@@ -97,13 +98,13 @@ describe MergeRequestObserver do ...@@ -97,13 +98,13 @@ describe MergeRequestObserver do
context '#after_reopen' do context '#after_reopen' do
context 'a status "reopened"' do context 'a status "reopened"' do
it 'note is created if the merge request is being reopened' do it 'note is created if the merge request is being reopened' do
Note.should_receive(:create_status_change_note).with(closed_assigned_mr, closed_assigned_mr.target_project, some_user, 'reopened', nil) Note.should_receive(:create_status_change_note).with(closed_assigned_mr, closed_assigned_mr.source_project, some_user, 'reopened', nil)
closed_assigned_mr.reopen closed_assigned_mr.reopen
end end
it 'notification is delivered only to author if the merge request is being reopened' do it 'notification is delivered only to author if the merge request is being reopened' do
Note.should_receive(:create_status_change_note).with(closed_unassigned_mr, closed_unassigned_mr.target_project, some_user, 'reopened', nil) Note.should_receive(:create_status_change_note).with(closed_unassigned_mr, closed_unassigned_mr.source_project, some_user, 'reopened', nil)
closed_unassigned_mr.reopen closed_unassigned_mr.reopen
end end
...@@ -118,20 +119,13 @@ describe MergeRequestObserver do ...@@ -118,20 +119,13 @@ describe MergeRequestObserver do
it { @event.project.should == project } it { @event.project.should == project }
end end
let(:project) { create(:project) }
before do before do
TestEnv.enable_observers @merge_request = create(:merge_request, source_project: project, source_project: project)
@merge_request = create(:merge_request, source_project: project, target_project: project)
@event = Event.last @event = Event.last
end end
after do
TestEnv.disable_observers
end
it_should_be_valid_event it_should_be_valid_event
it { @event.action.should == Event::CREATED } it { @event.action.should == Event::CREATED }
it { @event.target.should == @merge_request } it { @event.target.should == @merge_request }
end end
end end
...@@ -6,7 +6,7 @@ describe API::API do ...@@ -6,7 +6,7 @@ describe API::API do
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project_with_code, namespace: user.namespace ) } let!(:project) { create(:project, namespace: user.namespace ) }
before { project.team << [user, :developer] } before { project.team << [user, :developer] }
describe "POST /projects/:id/repository/files" do describe "POST /projects/:id/repository/files" do
......
...@@ -5,7 +5,7 @@ describe API::API do ...@@ -5,7 +5,7 @@ describe API::API do
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let!(:project) {create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:merge_request) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "Test") } let!(:merge_request) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "Test") }
before { before {
project.team << [user, :reporters] project.team << [user, :reporters]
...@@ -80,8 +80,8 @@ describe API::API do ...@@ -80,8 +80,8 @@ describe API::API do
context 'forked projects' do context 'forked projects' do
let!(:user2) {create(:user)} let!(:user2) {create(:user)}
let!(:forked_project_link) { build(:forked_project_link) } let!(:forked_project_link) { build(:forked_project_link) }
let!(:fork_project) { create(:source_project_with_code, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) } let!(:fork_project) { create(:source_project, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) }
let!(:unrelated_project) { create(:target_project_with_code, namespace: user2.namespace, creator_id: user2.id) } let!(:unrelated_project) { create(:target_project, namespace: user2.namespace, creator_id: user2.id) }
before :each do |each| before :each do |each|
fork_project.team << [user2, :reporters] fork_project.team << [user2, :reporters]
......
...@@ -7,7 +7,7 @@ describe API::API, 'ProjectHooks' do ...@@ -7,7 +7,7 @@ describe API::API, 'ProjectHooks' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let!(:project) { create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:hook) { create(:project_hook, project: project, url: "http://example.com") } let!(:hook) { create(:project_hook, project: project, url: "http://example.com") }
before do before do
......
...@@ -9,14 +9,14 @@ describe API::API do ...@@ -9,14 +9,14 @@ describe API::API do
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let!(:project) { create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') }
let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } let(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) }
let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } let(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) }
before { project.team << [user, :reporter] }
describe "GET /projects" do describe "GET /projects" do
before { project }
context "when unauthenticated" do context "when unauthenticated" do
it "should return authentication error" do it "should return authentication error" do
get api("/projects") get api("/projects")
...@@ -36,6 +36,8 @@ describe API::API do ...@@ -36,6 +36,8 @@ describe API::API do
end end
describe "GET /projects/all" do describe "GET /projects/all" do
before { project }
context "when unauthenticated" do context "when unauthenticated" do
it "should return authentication error" do it "should return authentication error" do
get api("/projects/all") get api("/projects/all")
...@@ -174,6 +176,7 @@ describe API::API do ...@@ -174,6 +176,7 @@ describe API::API do
end end
describe "POST /projects/user/:id" do describe "POST /projects/user/:id" do
before { project }
before { admin } before { admin }
it "should create new project without path" do it "should create new project without path" do
...@@ -255,6 +258,8 @@ describe API::API do ...@@ -255,6 +258,8 @@ describe API::API do
end end
describe "GET /projects/:id" do describe "GET /projects/:id" do
before { project }
it "should return a project by id" do it "should return a project by id" do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
response.status.should == 200 response.status.should == 200
...@@ -282,6 +287,8 @@ describe API::API do ...@@ -282,6 +287,8 @@ describe API::API do
end end
describe "GET /projects/:id/events" do describe "GET /projects/:id/events" do
before { users_project }
it "should return a project events" do it "should return a project events" do
get api("/projects/#{project.id}/events", user) get api("/projects/#{project.id}/events", user)
response.status.should == 200 response.status.should == 200
...@@ -305,6 +312,9 @@ describe API::API do ...@@ -305,6 +312,9 @@ describe API::API do
end end
describe "GET /projects/:id/members" do describe "GET /projects/:id/members" do
before { users_project }
before { users_project2 }
it "should return project team members" do it "should return project team members" do
get api("/projects/#{project.id}/members", user) get api("/projects/#{project.id}/members", user)
response.status.should == 200 response.status.should == 200
...@@ -328,6 +338,8 @@ describe API::API do ...@@ -328,6 +338,8 @@ describe API::API do
end end
describe "GET /projects/:id/members/:user_id" do describe "GET /projects/:id/members/:user_id" do
before { users_project }
it "should return project team member" do it "should return project team member" do
get api("/projects/#{project.id}/members/#{user.id}", user) get api("/projects/#{project.id}/members/#{user.id}", user)
response.status.should == 200 response.status.should == 200
...@@ -383,6 +395,8 @@ describe API::API do ...@@ -383,6 +395,8 @@ describe API::API do
end end
describe "PUT /projects/:id/members/:user_id" do describe "PUT /projects/:id/members/:user_id" do
before { users_project2 }
it "should update project team member" do it "should update project team member" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: UsersProject::MASTER put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: UsersProject::MASTER
response.status.should == 200 response.status.should == 200
...@@ -407,6 +421,9 @@ describe API::API do ...@@ -407,6 +421,9 @@ describe API::API do
end end
describe "DELETE /projects/:id/members/:user_id" do describe "DELETE /projects/:id/members/:user_id" do
before { users_project }
before { users_project2 }
it "should remove user from project team" do it "should remove user from project team" do
expect { expect {
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
...@@ -425,9 +442,7 @@ describe API::API do ...@@ -425,9 +442,7 @@ describe API::API do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
response.status.should == 200 response.status.should == 200
end end
end
describe "DELETE /projects/:id/members/:user_id" do
it "should return 200 OK when the user was not member" do it "should return 200 OK when the user was not member" do
expect { expect {
delete api("/projects/#{project.id}/members/1000000", user) delete api("/projects/#{project.id}/members/1000000", user)
...@@ -439,6 +454,8 @@ describe API::API do ...@@ -439,6 +454,8 @@ describe API::API do
end end
describe "GET /projects/:id/snippets" do describe "GET /projects/:id/snippets" do
before { snippet }
it "should return an array of project snippets" do it "should return an array of project snippets" do
get api("/projects/#{project.id}/snippets", user) get api("/projects/#{project.id}/snippets", user)
response.status.should == 200 response.status.should == 200
...@@ -505,6 +522,8 @@ describe API::API do ...@@ -505,6 +522,8 @@ describe API::API do
end end
describe "DELETE /projects/:id/snippets/:snippet_id" do describe "DELETE /projects/:id/snippets/:snippet_id" do
before { snippet }
it "should delete existing project snippet" do it "should delete existing project snippet" do
expect { expect {
delete api("/projects/#{project.id}/snippets/#{snippet.id}", user) delete api("/projects/#{project.id}/snippets/#{snippet.id}", user)
...@@ -657,15 +676,15 @@ describe API::API do ...@@ -657,15 +676,15 @@ describe API::API do
describe "GET /projects/search/:query" do describe "GET /projects/search/:query" do
let!(:query) { 'query'} let!(:query) { 'query'}
let!(:search) { create(:project, name: query, creator_id: user.id, namespace: user.namespace) } let!(:search) { create(:empty_project, name: query, creator_id: user.id, namespace: user.namespace) }
let!(:pre) { create(:project, name: "pre_#{query}", creator_id: user.id, namespace: user.namespace) } let!(:pre) { create(:empty_project, name: "pre_#{query}", creator_id: user.id, namespace: user.namespace) }
let!(:post) { create(:project, name: "#{query}_post", creator_id: user.id, namespace: user.namespace) } let!(:post) { create(:empty_project, name: "#{query}_post", creator_id: user.id, namespace: user.namespace) }
let!(:pre_post) { create(:project, name: "pre_#{query}_post", creator_id: user.id, namespace: user.namespace) } let!(:pre_post) { create(:empty_project, name: "pre_#{query}_post", creator_id: user.id, namespace: user.namespace) }
let!(:unfound) { create(:project, name: 'unfound', creator_id: user.id, namespace: user.namespace) } let!(:unfound) { create(:empty_project, name: 'unfound', creator_id: user.id, namespace: user.namespace) }
let!(:internal) { create(:project, name: "internal #{query}", visibility_level: Gitlab::VisibilityLevel::INTERNAL) } let!(:internal) { create(:empty_project, name: "internal #{query}", visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
let!(:unfound_internal) { create(:project, name: 'unfound internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL) } let!(:unfound_internal) { create(:empty_project, name: 'unfound internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
let!(:public) { create(:project, name: "public #{query}", visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let!(:public) { create(:empty_project, name: "public #{query}", visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let!(:unfound_public) { create(:project, name: 'unfound public', visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let!(:unfound_public) { create(:empty_project, name: 'unfound public', visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
context "when unauthenticated" do context "when unauthenticated" do
it "should return authentication error" do it "should return authentication error" do
......
...@@ -8,7 +8,7 @@ describe API::API do ...@@ -8,7 +8,7 @@ describe API::API do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project_with_code, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) }
let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) } let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) }
......
...@@ -6,7 +6,7 @@ describe API::API do ...@@ -6,7 +6,7 @@ describe API::API do
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let(:project) {create(:project, creator_id: user.id, namespace: user.namespace) }
describe "POST /projects/:id/services/gitlab-ci" do describe "POST /projects/:id/services/gitlab-ci" do
it "should update gitlab-ci settings" do it "should update gitlab-ci settings" do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe GitPushService do describe GitPushService do
let (:user) { create :user } let (:user) { create :user }
let (:project) { create :project_with_code } let (:project) { create :project }
let (:service) { GitPushService.new } let (:service) { GitPushService.new }
before do before do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe TestHookService do describe TestHookService do
let (:user) { create :user } let (:user) { create :user }
let (:project) { create :project_with_code } let (:project) { create :project }
let (:hook) { create :project_hook, project: project } let (:hook) { create :project_hook, project: project }
describe :execute do describe :execute do
......
...@@ -11,7 +11,7 @@ def common_mentionable_setup ...@@ -11,7 +11,7 @@ def common_mentionable_setup
let(:mentioned_issue) { create :issue, project: mproject } let(:mentioned_issue) { create :issue, project: mproject }
let(:other_issue) { create :issue, project: mproject } let(:other_issue) { create :issue, project: mproject }
let(:mentioned_mr) { create :merge_request, target_project: mproject, source_branch: 'different' } let(:mentioned_mr) { create :merge_request, source_project: mproject, source_branch: 'different' }
let(:mentioned_commit) { double('commit', sha: '1234567890abcdef').as_null_object } let(:mentioned_commit) { double('commit', sha: '1234567890abcdef').as_null_object }
# Override to add known commits to the repository stub. # Override to add known commits to the repository stub.
......
...@@ -9,7 +9,7 @@ describe PostReceive do ...@@ -9,7 +9,7 @@ describe PostReceive do
end end
context "web hook" do context "web hook" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:key) { create(:key, user: project.owner) } let(:key) { create(:key, user: project.owner) }
let(:key_id) { key.shell_id } let(:key_id) { key.shell_id }
......
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