diff options
Diffstat (limited to 'spec/models/issue_spec.rb')
-rw-r--r-- | spec/models/issue_spec.rb | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 3c34b1d397f..fac516f9568 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -152,6 +152,11 @@ describe Issue, models: true do it { is_expected.to eq true } + context 'issue not persisted' do + let(:issue) { build(:issue, project: project) } + it { is_expected.to eq false } + end + context 'checking destination project also' do subject { issue.can_move?(user, to_project) } let(:to_project) { create(:project) } @@ -186,12 +191,19 @@ describe Issue, models: true do end describe '#related_branches' do - it "selects the right branches" do + it 'selects the right branches' do allow(subject.project.repository).to receive(:branch_names). - and_return(["mpempe", "#{subject.iid}mepmep", subject.to_branch_name]) + and_return(['mpempe', "#{subject.iid}mepmep", subject.to_branch_name]) expect(subject.related_branches).to eq([subject.to_branch_name]) end + + it 'excludes stable branches from the related branches' do + allow(subject.project.repository).to receive(:branch_names). + and_return(["#{subject.iid}-0-stable"]) + + expect(subject.related_branches).to eq [] + end end it_behaves_like 'an editable mentionable' do @@ -205,11 +217,11 @@ describe Issue, models: true do let(:subject) { create :issue } end - describe "#to_branch_name" do + describe '#to_branch_name' do let(:issue) { create(:issue, title: 'a' * 30) } - it "starts with the issue iid" do - expect(issue.to_branch_name).to match /-#{issue.iid}\z/ + it 'starts with the issue iid' do + expect(issue.to_branch_name).to match /\A#{issue.iid}-a+\z/ end end end |