2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Explore::GroupsController do
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
shared_examples 'explore groups' do
|
|
|
|
it 'renders group trees' do
|
|
|
|
expect(described_class).to include(GroupTree)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'includes public projects' do
|
|
|
|
member_of_group = create(:group)
|
|
|
|
member_of_group.add_developer(user)
|
|
|
|
public_group = create(:group, :public)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
get :index
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
expect(assigns(:groups)).to contain_exactly(member_of_group, public_group)
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
context 'restricted visibility level is public' do
|
|
|
|
before do
|
|
|
|
sign_out(user)
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'redirects to login page' do
|
|
|
|
get :index
|
|
|
|
|
|
|
|
expect(response).to redirect_to new_user_session_path
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it_behaves_like 'explore groups'
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
context 'gitlab.com' do
|
2023-01-13 00:05:48 +05:30
|
|
|
before do
|
2023-05-27 22:25:52 +05:30
|
|
|
allow(Gitlab).to receive(:com?).and_return(true)
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
it_behaves_like 'explore groups'
|
2020-04-22 19:07:51 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|