debian-mirror-gitlab/spec/finders/users_star_projects_finder_spec.rb

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

53 lines
1.3 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe UsersStarProjectsFinder do
2019-10-12 21:52:04 +05:30
let(:project) { create(:project, :public, :empty_repo) }
let(:user) { create(:user) }
let(:private_user) { create(:user, private_profile: true) }
let(:other_user) { create(:user) }
2023-01-13 00:05:48 +05:30
let(:blocked_user) { create(:user, state: 'blocked') }
2019-10-12 21:52:04 +05:30
before do
user.toggle_star(project)
private_user.toggle_star(project)
2023-01-13 00:05:48 +05:30
blocked_user.toggle_star(project)
2019-10-12 21:52:04 +05:30
end
describe '#execute' do
let(:finder) { described_class.new(project, {}, current_user: current_user) }
let(:public_stars) { user.users_star_projects }
let(:private_stars) { private_user.users_star_projects }
subject { finder.execute }
describe 'as same user' do
let(:current_user) { private_user }
it { is_expected.to match_array(private_stars + public_stars) }
end
describe 'as other user' do
let(:current_user) { other_user }
it { is_expected.to match_array(public_stars) }
end
describe 'as no user' do
let(:current_user) { nil }
it { is_expected.to match_array(public_stars) }
end
2023-01-13 00:05:48 +05:30
describe 'with active users only' do
let(:current_user) { private_user }
it 'ignores stars of non-active users' do
is_expected.not_to include(*blocked_user.users_star_projects)
end
end
2019-10-12 21:52:04 +05:30
end
end