debian-mirror-gitlab/spec/features/profiles/user_visits_profile_spec.rb

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

148 lines
4.1 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +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 'User visits their profile' do
2022-05-07 20:08:51 +05:30
let_it_be_with_refind(:user) { create(:user) }
2018-03-17 18:26:18 +05:30
before do
sign_in(user)
end
it 'shows correct menu item' do
2018-03-27 19:54:05 +05:30
visit(profile_path)
2018-03-17 18:26:18 +05:30
expect(page).to have_active_navigation('Profile')
end
2018-03-27 19:54:05 +05:30
it 'shows profile info' do
visit(profile_path)
expect(page).to have_content "This information will appear on your profile"
end
2021-12-11 22:18:48 +05:30
it 'shows user readme' do
create(:project, :repository, :public, path: user.username, namespace: user.namespace)
visit(user_path(user))
expect(find('.file-content')).to have_content('testme')
end
2022-01-26 12:08:38 +05:30
it 'hides empty user readme' do
project = create(:project, :repository, :public, path: user.username, namespace: user.namespace)
Files::UpdateService.new(
project,
user,
start_branch: 'master',
branch_name: 'master',
commit_message: 'Update feature',
file_path: 'README.md',
file_content: ''
).execute
visit(user_path(user))
expect(page).not_to have_selector('.file-content')
end
2018-03-27 19:54:05 +05:30
context 'when user has groups' do
let(:group) do
create :group do |group|
group.add_owner(user)
end
end
let!(:project) do
create(:project, :repository, namespace: group) do |project|
create(:closed_issue_event, project: project)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
2018-03-27 19:54:05 +05:30
end
end
def click_on_profile_picture
find(:css, '.header-user-dropdown-toggle').click
page.within ".header-user" do
2021-03-11 19:13:27 +05:30
click_link user.username
2018-03-27 19:54:05 +05:30
end
end
it 'shows user groups', :js do
visit(profile_path)
click_on_profile_picture
page.within ".cover-block" do
expect(page).to have_content user.name
expect(page).to have_content user.username
end
page.within ".content" do
click_link "Groups"
end
2018-03-17 18:26:18 +05:30
2018-03-27 19:54:05 +05:30
page.within "#groups" do
expect(page).to have_content group.name
end
2018-03-17 18:26:18 +05:30
end
end
2022-05-07 20:08:51 +05:30
describe 'storage_enforcement_banner', :js do
2022-07-23 23:45:48 +05:30
before do
stub_feature_flags(namespace_storage_limit_bypass_date_check: false)
end
2022-05-07 20:08:51 +05:30
context 'with storage_enforcement_date set' do
let_it_be(:storage_enforcement_date) { Date.today + 30 }
before do
2022-08-27 11:52:29 +05:30
allow_next_found_instance_of(Namespaces::UserNamespace) do |user_namespace|
allow(user_namespace).to receive(:storage_enforcement_date).and_return(storage_enforcement_date)
2022-05-07 20:08:51 +05:30
end
end
it 'displays the banner in the profile page' do
visit(profile_path)
expect_page_to_have_storage_enforcement_banner(storage_enforcement_date)
end
it 'does not display the banner if user has previously closed unless threshold has changed' do
visit(profile_path)
expect_page_to_have_storage_enforcement_banner(storage_enforcement_date)
find('.js-storage-enforcement-banner [data-testid="close-icon"]').click
page.refresh
expect_page_not_to_have_storage_enforcement_banner
storage_enforcement_date = Date.today + 13
2022-08-27 11:52:29 +05:30
allow_next_found_instance_of(Namespaces::UserNamespace) do |user_namespace|
allow(user_namespace).to receive(:storage_enforcement_date).and_return(storage_enforcement_date)
2022-05-07 20:08:51 +05:30
end
page.refresh
expect_page_to_have_storage_enforcement_banner(storage_enforcement_date)
end
end
context 'with storage_enforcement_date not set' do
2022-08-27 11:52:29 +05:30
before do
allow_next_found_instance_of(Namespaces::UserNamespace) do |user_namespace|
allow(user_namespace).to receive(:storage_enforcement_date).and_return(nil)
end
end
2022-05-07 20:08:51 +05:30
it 'does not display the banner in the group page' do
visit(profile_path)
expect_page_not_to_have_storage_enforcement_banner
end
end
end
def expect_page_to_have_storage_enforcement_banner(storage_enforcement_date)
2022-08-27 11:52:29 +05:30
expect(page).to have_text "Effective #{storage_enforcement_date}, namespace storage limits will apply"
2022-05-07 20:08:51 +05:30
end
def expect_page_not_to_have_storage_enforcement_banner
2022-08-27 11:52:29 +05:30
expect(page).not_to have_text "namespace storage limits will apply"
2022-05-07 20:08:51 +05:30
end
2018-03-17 18:26:18 +05:30
end