gitlab-org--gitlab-foss/spec/finders/starred_projects_finder_spec.rb

42 lines
999 B
Ruby
Raw Normal View History

2019-08-03 06:57:33 -04:00
# frozen_string_literal: true
2019-02-05 06:49:58 -05:00
require 'spec_helper'
describe StarredProjectsFinder do
let(:project1) { create(:project, :public, :empty_repo) }
let(:project2) { create(:project, :public, :empty_repo) }
let(:other_project) { create(:project, :public, :empty_repo) }
let(:user) { create(:user) }
let(:other_user) { create(:user) }
before do
user.toggle_star(project1)
user.toggle_star(project2)
end
describe '#execute' do
let(:finder) { described_class.new(user, params: {}, current_user: current_user) }
subject { finder.execute }
describe 'as same user' do
let(:current_user) { user }
2019-08-03 06:57:33 -04:00
it { is_expected.to contain_exactly(project1, project2) }
2019-02-05 06:49:58 -05:00
end
describe 'as other user' do
let(:current_user) { other_user }
2019-08-03 06:57:33 -04:00
it { is_expected.to contain_exactly(project1, project2) }
2019-02-05 06:49:58 -05:00
end
describe 'as no user' do
let(:current_user) { nil }
2019-08-03 06:57:33 -04:00
it { is_expected.to contain_exactly(project1, project2) }
2019-02-05 06:49:58 -05:00
end
end
end