diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-07 18:06:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-07 18:06:21 +0000 |
commit | d8ccc7a00b7a1ea954263170a2044257424a2cfe (patch) | |
tree | 0a29cb558aae61795da47c82ce7e87983c5dc4af /spec/models/concerns/issuable_spec.rb | |
parent | 90a06a20be61bb6d48d77746091492831153e075 (diff) | |
download | gitlab-ce-d8ccc7a00b7a1ea954263170a2044257424a2cfe.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/concerns/issuable_spec.rb')
-rw-r--r-- | spec/models/concerns/issuable_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index e8116f0a301..f7bef9e71e2 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -111,6 +111,34 @@ describe Issuable do end end + describe '.initialize' do + it 'maps the state to the right state_id' do + described_class::STATE_ID_MAP.each do |key, value| + issuable = MergeRequest.new(state: key) + + expect(issuable.state).to eq(key) + expect(issuable.state_id).to eq(value) + end + end + + it 'maps a string version of the state to the right state_id' do + described_class::STATE_ID_MAP.each do |key, value| + issuable = MergeRequest.new('state' => key) + + expect(issuable.state).to eq(key) + expect(issuable.state_id).to eq(value) + end + end + + it 'gives preference to state_id if present' do + issuable = MergeRequest.new('state' => 'opened', + 'state_id' => described_class::STATE_ID_MAP['merged']) + + expect(issuable.state).to eq('merged') + expect(issuable.state_id).to eq(described_class::STATE_ID_MAP['merged']) + end + end + describe '#milestone_available?' do let(:group) { create(:group) } let(:project) { create(:project, group: group) } |