merge_request_spec.rb 1.6 KB
Newer Older
D
Dmitriy Zaporozhets 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# == Schema Information
#
# Table name: merge_requests
#
#  id            :integer         not null, primary key
#  target_branch :string(255)     not null
#  source_branch :string(255)     not null
#  project_id    :integer         not null
#  author_id     :integer
#  assignee_id   :integer
#  title         :string(255)
#  closed        :boolean         default(FALSE), not null
#  created_at    :datetime        not null
#  updated_at    :datetime        not null
#  st_commits    :text(4294967295
#  st_diffs      :text(4294967295
#  merged        :boolean         default(FALSE), not null
#  state         :integer         default(1), not null
#

D
Dmitriy Zaporozhets 已提交
21 22 23
require 'spec_helper'

describe MergeRequest do
D
Dmitriy Zaporozhets 已提交
24 25 26 27 28
  describe "Validation" do
    it { should validate_presence_of(:target_branch) }
    it { should validate_presence_of(:source_branch) }
  end

29 30 31 32 33
  describe "Mass assignment" do
    it { should_not allow_mass_assignment_of(:author_id) }
    it { should_not allow_mass_assignment_of(:project_id) }
  end

34 35
  describe 'modules' do
    it { should include_module(IssueCommonality) }
R
Riyad Preukschas 已提交
36
    it { should include_module(Votes) }
37
  end
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

  describe "#mr_and_commit_notes" do
    let!(:merge_request) { Factory.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)
    end

    it "should include notes for commits" do
      merge_request.commits.should_not be_empty
      merge_request.mr_and_commit_notes.count.should == 2
    end
  end
D
Dmitriy Zaporozhets 已提交
53
end