debian-mirror-gitlab/spec/lib/bitbucket/representation/pull_request_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
2.2 KiB
Ruby
Raw Permalink Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'fast_spec_helper'
2017-08-17 22:00:37 +05:30
2020-07-28 23:09:34 +05:30
RSpec.describe Bitbucket::Representation::PullRequest do
2017-08-17 22:00:37 +05:30
describe '#iid' do
it { expect(described_class.new('id' => 1).iid).to eq(1) }
end
describe '#author' do
2019-10-12 21:52:04 +05:30
it { expect(described_class.new({ 'author' => { 'nickname' => 'Ben' } }).author).to eq('Ben') }
2017-08-17 22:00:37 +05:30
it { expect(described_class.new({}).author).to be_nil }
end
describe '#description' do
it { expect(described_class.new({ 'description' => 'Text' }).description).to eq('Text') }
it { expect(described_class.new({}).description).to be_nil }
end
describe '#state' do
it { expect(described_class.new({ 'state' => 'MERGED' }).state).to eq('merged') }
it { expect(described_class.new({ 'state' => 'DECLINED' }).state).to eq('closed') }
2019-12-26 22:10:19 +05:30
it { expect(described_class.new({ 'state' => 'SUPERSEDED' }).state).to eq('closed') }
2017-08-17 22:00:37 +05:30
it { expect(described_class.new({}).state).to eq('opened') }
end
describe '#title' do
it { expect(described_class.new('title' => 'Issue').title).to eq('Issue') }
end
describe '#source_branch_name' do
it { expect(described_class.new({ source: { branch: { name: 'feature' } } }.with_indifferent_access).source_branch_name).to eq('feature') }
it { expect(described_class.new({ source: {} }.with_indifferent_access).source_branch_name).to be_nil }
end
describe '#source_branch_sha' do
it { expect(described_class.new({ source: { commit: { hash: 'abcd123' } } }.with_indifferent_access).source_branch_sha).to eq('abcd123') }
it { expect(described_class.new({ source: {} }.with_indifferent_access).source_branch_sha).to be_nil }
end
describe '#target_branch_name' do
it { expect(described_class.new({ destination: { branch: { name: 'master' } } }.with_indifferent_access).target_branch_name).to eq('master') }
it { expect(described_class.new({ destination: {} }.with_indifferent_access).target_branch_name).to be_nil }
end
describe '#target_branch_sha' do
it { expect(described_class.new({ destination: { commit: { hash: 'abcd123' } } }.with_indifferent_access).target_branch_sha).to eq('abcd123') }
it { expect(described_class.new({ destination: {} }.with_indifferent_access).target_branch_sha).to be_nil }
end
end