BigW Consortium Gitlab

issue_spec.rb 1.57 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 { is_expected.to belong_to(:milestone) }
gitlabhq committed
25 26
  end

27 28 29
  describe "Mass assignment" do
  end

30
  describe 'modules' do
31
    it { is_expected.to include_module(Issuable) }
32 33
  end

34
  subject { create(:issue) }
35 36 37

  describe '#is_being_reassigned?' do
    it 'returns true if the issue assignee has changed' do
38
      subject.assignee = create(:user)
39
      expect(subject.is_being_reassigned?).to be_truthy
40 41
    end
    it 'returns false if the issue assignee has not changed' do
42
      expect(subject.is_being_reassigned?).to be_falsey
43 44
    end
  end
45 46

  describe '#is_being_reassigned?' do
Johannes Schleifenbaum committed
47
    it 'returns issues assigned to user' do
48 49 50 51 52 53
      user = create :user

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

54
      expect(Issue.open_for(user).count).to eq 2
55 56
    end
  end
57 58 59 60 61 62

  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
Vinnie Okada committed
63 64 65 66

  it_behaves_like 'a Taskable' do
    let(:subject) { create :issue }
  end
gitlabhq committed
67
end