Commit 9338ed06 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix project and notes specs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 7e168093
...@@ -62,43 +62,6 @@ FactoryGirl.define do ...@@ -62,43 +62,6 @@ FactoryGirl.define do
factory :reopened_issue, traits: [:reopened] factory :reopened_issue, traits: [:reopened]
end 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 :event do
factory :closed_issue_event do factory :closed_issue_event do
project project
......
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
...@@ -124,24 +124,21 @@ describe Project do ...@@ -124,24 +124,21 @@ describe Project do
describe :update_merge_requests do describe :update_merge_requests do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
before do let(:key) { create(:key, user_id: project.owner.id) }
@merge_request = create(:merge_request, source_project: project, target_project: project) let(:prev_commit_id) { merge_request.commits.last.id }
@key = create(:key, user_id: project.owner.id) let(:commit_id) { merge_request.commits.first.id }
end
it "should close merge request if last commit from source branch was pushed to target branch" do it "should close merge request if last commit from source branch was pushed to target branch" do
@merge_request.reload_code project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.target_branch}", key.user)
@merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba" merge_request.reload
project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/stable", @key.user) merge_request.merged?.should be_true
@merge_request.reload
@merge_request.merged?.should be_true
end end
it "should update merge request commits with new one if pushed to source branch" do 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) project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.source_branch}", key.user)
@merge_request.reload merge_request.reload
@merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba" merge_request.last_commit.id.should == commit_id
end end
end end
...@@ -237,7 +234,7 @@ describe Project do ...@@ -237,7 +234,7 @@ describe Project do
project.protected_branches.create(name: 'master') project.protected_branches.create(name: 'master')
end 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') } it { project.open_branches.map(&:name).should_not include('master') }
end end
......
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