diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-26 00:10:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-26 00:10:28 +0300 |
commit | 52f765baf4931efd40d10b1eb5f2818923ddf26f (patch) | |
tree | 5cdbe4c6aa08be4b829316b0d80f94d46c305703 /spec/lib | |
parent | b98791fe502a4dfc02b70d3fa4b4140afb69d7d9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/changelog/config_spec.rb | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/spec/lib/gitlab/changelog/config_spec.rb b/spec/lib/gitlab/changelog/config_spec.rb index a464c1e57e5..ff5a084bb86 100644 --- a/spec/lib/gitlab/changelog/config_spec.rb +++ b/spec/lib/gitlab/changelog/config_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe Gitlab::Changelog::Config do + include ProjectForksHelper + let(:project) { build_stubbed(:project) } describe '.from_git' do @@ -66,20 +68,33 @@ RSpec.describe Gitlab::Changelog::Config do end describe '#contributor?' do - it 'returns true if a user is a contributor' do - user = build_stubbed(:author) - - allow(project.team).to receive(:contributor?).with(user).and_return(true) + let(:project) { create(:project, :public, :repository) } - expect(described_class.new(project).contributor?(user)).to eq(true) - end + context 'when user is a member of project' do + let(:user) { create(:user) } - it "returns true if a user isn't a contributor" do - user = build_stubbed(:author) + before do + project.add_developer(user) + end - allow(project.team).to receive(:contributor?).with(user).and_return(false) + it { expect(described_class.new(project).contributor?(user)).to eq(false) } + end - expect(described_class.new(project).contributor?(user)).to eq(false) + context 'when user has at least one merge request merged into default_branch' do + let(:contributor) { create(:user) } + let(:user_without_access) { create(:user) } + let(:user_fork) { fork_project(project, contributor, repository: true) } + + before do + create(:merge_request, :merged, + author: contributor, + target_project: project, + source_project: user_fork, + target_branch: project.default_branch.to_s) + end + + it { expect(described_class.new(project).contributor?(contributor)).to eq(true) } + it { expect(described_class.new(project).contributor?(user_without_access)).to eq(false) } end end |