BigW Consortium Gitlab

issue_spec.rb 1.58 KB
Newer Older
Dmitriy Zaporozhets committed
1 2 3 4
# == Schema Information
#
# Table name: issues
#
5
#  id           :integer          not null, primary key
Dmitriy Zaporozhets committed
6 7 8 9
#  title        :string(255)
#  assignee_id  :integer
#  author_id    :integer
#  project_id   :integer
Dmitriy Zaporozhets committed
10 11
#  created_at   :datetime
#  updated_at   :datetime
12
#  position     :integer          default(0)
Dmitriy Zaporozhets committed
13 14 15
#  branch_name  :string(255)
#  description  :text
#  milestone_id :integer
Dmitriy Zaporozhets committed
16
#  state        :string(255)
Dmitriy Zaporozhets committed
17
#  iid          :integer
Dmitriy Zaporozhets committed
18 19
#

gitlabhq committed
20 21 22 23
require 'spec_helper'

describe Issue do
  describe "Associations" do
24
    it { should belong_to(:milestone) }
gitlabhq committed
25 26
  end

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

32
  describe 'modules' do
33
    it { should include_module(Issuable) }
34 35
  end

36
  subject { create(:issue) }
37 38 39

  describe '#is_being_reassigned?' do
    it 'returns true if the issue assignee has changed' do
40
      subject.assignee = create(:user)
41 42 43 44 45 46
      subject.is_being_reassigned?.should be_true
    end
    it 'returns false if the issue assignee has not changed' do
      subject.is_being_reassigned?.should be_false
    end
  end
47 48

  describe '#is_being_reassigned?' do
Johannes Schleifenbaum committed
49
    it 'returns issues assigned to user' do
50 51 52 53 54 55 56 57 58
      user = create :user

      2.times do
        issue = create :issue, assignee: user
      end

      Issue.open_for(user).count.should eq 2
    end
  end
59 60 61 62 63 64

  it_behaves_like 'an editable mentionable' do
    let(:subject) { create :issue, project: mproject }
    let(:backref_text) { "issue ##{subject.iid}" }
    let(:set_mentionable_text) { ->(txt){ subject.description = txt } }
  end
gitlabhq committed
65
end