Commit 7926876d authored by Rajat Jain's avatar Rajat Jain

Failsafe access to users email

Failsafe access to users email
parent a63eef73
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
opened: requirements_count['opened'], opened: requirements_count['opened'],
archived: requirements_count['archived'], archived: requirements_count['archived'],
all: total_requirements, all: total_requirements,
current_user_email: current_user.email, current_user_email: current_user&.email,
requirements_web_url: project_requirements_management_requirements_path(@project), requirements_web_url: project_requirements_management_requirements_path(@project),
can_create_requirement: "#{can?(current_user, :create_requirement, @project)}", can_create_requirement: "#{can?(current_user, :create_requirement, @project)}",
description_preview_path: preview_markdown_path(@project), description_preview_path: preview_markdown_path(@project),
......
---
title: Fix rendering of requirements page for unauthenticated users
merge_request: 52069
author:
type: fixed
...@@ -5,7 +5,8 @@ require 'spec_helper' ...@@ -5,7 +5,8 @@ require 'spec_helper'
RSpec.describe 'Requirements list', :js do RSpec.describe 'Requirements list', :js do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:user_guest) { create(:user) } let_it_be(:user_guest) { create(:user) }
let_it_be(:project) { create(:project, :repository) } let_it_be(:project) { create(:project) }
let_it_be(:public_project) { create(:project, :public) }
let_it_be(:requirement1) { create(:requirement, project: project, title: 'Some requirement-1', description: 'Sample description', author: user, created_at: 5.days.ago, updated_at: 2.days.ago) } let_it_be(:requirement1) { create(:requirement, project: project, title: 'Some requirement-1', description: 'Sample description', author: user, created_at: 5.days.ago, updated_at: 2.days.ago) }
let_it_be(:requirement2) { create(:requirement, project: project, title: 'Some requirement-2', description: 'Sample description', author: user, created_at: 6.days.ago, updated_at: 2.days.ago) } let_it_be(:requirement2) { create(:requirement, project: project, title: 'Some requirement-2', description: 'Sample description', author: user, created_at: 6.days.ago, updated_at: 2.days.ago) }
let_it_be(:requirement3) { create(:requirement, project: project, title: 'Some requirement-3', description: 'Sample description', author: user, created_at: 7.days.ago, updated_at: 2.days.ago) } let_it_be(:requirement3) { create(:requirement, project: project, title: 'Some requirement-3', description: 'Sample description', author: user, created_at: 7.days.ago, updated_at: 2.days.ago) }
...@@ -280,4 +281,17 @@ RSpec.describe 'Requirements list', :js do ...@@ -280,4 +281,17 @@ RSpec.describe 'Requirements list', :js do
expect(page).not_to have_selector('.nav-controls button.js-new-requirement') expect(page).not_to have_selector('.nav-controls button.js-new-requirement')
end end
end end
context 'when accessing project as logged out user' do
before do
sign_out user
visit project_requirements_management_requirements_path(public_project)
wait_for_requests
end
it 'renders the empty state' do
expect(page).to have_selector('.requirements-empty-state-container')
end
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment