Fix project and notes specs

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2014-08-01 17:54:44 +03:00
parent 7e1680934b
commit 9338ed0606
No known key found for this signature in database
GPG key ID: 627C5F589F467F17
3 changed files with 51 additions and 51 deletions

View file

@ -62,43 +62,6 @@ FactoryGirl.define do
factory :reopened_issue, traits: [:reopened]
end
factory :note do
project
note "Note"
author
factory :note_on_commit, traits: [:on_commit]
factory :note_on_commit_diff, traits: [:on_commit, :on_diff]
factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
factory :note_on_merge_request, traits: [:on_merge_request]
factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff]
trait :on_commit do
project factory: :project
commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
noteable_type "Commit"
end
trait :on_diff do
line_code "0_184_184"
end
trait :on_merge_request do
project factory: :project
noteable_id 1
noteable_type "MergeRequest"
end
trait :on_issue do
noteable_id 1
noteable_type "Issue"
end
trait :with_attachment do
attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "`/png") }
end
end
factory :event do
factory :closed_issue_event do
project

40
spec/factories/notes.rb Normal file
View file

@ -0,0 +1,40 @@
require_relative '../support/repo_helpers'
FactoryGirl.define do
factory :note do
project
note "Note"
author
factory :note_on_commit, traits: [:on_commit]
factory :note_on_commit_diff, traits: [:on_commit, :on_diff]
factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
factory :note_on_merge_request, traits: [:on_merge_request]
factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff]
trait :on_commit do
project factory: :project
commit_id RepoHelpers.sample_commit.id
noteable_type "Commit"
end
trait :on_diff do
line_code "0_184_184"
end
trait :on_merge_request do
project factory: :project
noteable_id 1
noteable_type "MergeRequest"
end
trait :on_issue do
noteable_id 1
noteable_type "Issue"
end
trait :with_attachment do
attachment { fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "`/png") }
end
end
end

View file

@ -124,24 +124,21 @@ describe Project do
describe :update_merge_requests do
let(:project) { create(:project) }
before do
@merge_request = create(:merge_request, source_project: project, target_project: project)
@key = create(:key, user_id: project.owner.id)
end
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:key) { create(:key, user_id: project.owner.id) }
let(:prev_commit_id) { merge_request.commits.last.id }
let(:commit_id) { merge_request.commits.first.id }
it "should close merge request if last commit from source branch was pushed to target branch" do
@merge_request.reload_code
@merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba"
project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/stable", @key.user)
@merge_request.reload
@merge_request.merged?.should be_true
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.target_branch}", key.user)
merge_request.reload
merge_request.merged?.should be_true
end
it "should update merge request commits with new one if pushed to source branch" do
project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/master", @key.user)
@merge_request.reload
@merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba"
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.source_branch}", key.user)
merge_request.reload
merge_request.last_commit.id.should == commit_id
end
end
@ -237,7 +234,7 @@ describe Project do
project.protected_branches.create(name: 'master')
end
it { project.open_branches.map(&:name).should include('bootstrap') }
it { project.open_branches.map(&:name).should include('feature') }
it { project.open_branches.map(&:name).should_not include('master') }
end