This repository has been archived by the owner on Jun 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 138
Temp Fix to restrict access for unconfirmed users #992
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
45fe849
Update Ability to restrict access for unconfirmed users.
emcoding 3772ed0
Remove redundant comments; cosmetic changes
emcoding ddb193a
Move helper methods back, which is outside of initializer
emcoding ab6c75c
Add :unconfirmed trait to user factory
emcoding 26cc087
Added extra expectations to test that admin.user can CRUD every user
emcoding 2564d86
FIX: Make sure user factory creates unique GitHub handles
emcoding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Guest Users', type: :feature do | ||
let!(:user) { create(:user) } # not the guest user; don't sign_in user | ||
let!(:project) { create(:project, :in_current_season, :accepted, submitter: user) } | ||
let!(:team1) { create(:team, name: 'Cheesy forever') } | ||
let!(:activity) { create(:status_update, :published, team: team1) } | ||
let(:out_of_season) { Season.current.starts_at - 1.week } | ||
let(:summer_season) { Season.current.starts_at + 1.week } | ||
|
||
context "when visiting public pages" do | ||
|
||
context 'all year' do | ||
before { Timecop.travel(out_of_season) } | ||
after { Timecop.return } | ||
|
||
it 'has restricted access to Activities page' do | ||
visit root_path | ||
expect(page).to have_css('h1', text: 'Activities') | ||
find('.title', match: :smart).click | ||
expect(page).to have_content(activity.title) | ||
expect(page).to have_content('You must be logged in to add a comment.') | ||
end | ||
|
||
it 'has restricted access to Community page' do | ||
visit community_path | ||
expect(page).to have_css('h1', text: 'Community') | ||
find_link(user.name, match: :first).click | ||
expect(page).to have_content("About me") | ||
expect(page).to have_link("All participants") | ||
expect(page).not_to have_link("Edit") # check | ||
end | ||
|
||
it 'has access to Projects page' do | ||
visit projects_path | ||
expect(page).to have_css('h1', text: 'Projects') # can be empty table | ||
end | ||
|
||
it 'has a menu with public links' do | ||
visit root_path | ||
expect(page).to have_link("Activities") | ||
find_link("Summer of Code").click | ||
expect(page).to have_link("Teams") | ||
expect(page).to have_link("Community") | ||
expect(page).to have_link("Help") | ||
end | ||
|
||
it 'has access to sign in link' do | ||
visit root_path | ||
expect(page).to have_link('Sign in') | ||
# story continues in sign_in_confirmed_user || sign_in_unconfirmed_user || sign_in_fail | ||
end | ||
end | ||
|
||
context 'in season' do | ||
before do | ||
Timecop.travel(summer_season) | ||
allow_any_instance_of(Project).to receive(:selected).and_return(:project) | ||
end | ||
after { Timecop.return } | ||
|
||
it 'has access to Projects index and show' do | ||
pending 'Stub needs updating; project not visible on page' | ||
visit projects_path | ||
expect(page).to have_css('h1', text: 'Projects') | ||
find_link(project.name, match: :smart).click | ||
expect(page).to have_content project.description | ||
expect(page).not_to have_link("Edit") | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understood correctly, but admins seem to be losing the ability to update users here. Is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the failing spec comes from here. Is there a reason we're removing admin access from
crud
'ing users?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admin can still crud User, it has moved to line 38.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My apologies! Dunno how I missed that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the admin call is guarded behind a
if user.confirmed?
. I feel we should keep the current behaviour. If anything, we want admins to be able to fix a user's typo'd email address as a response to a support request ticket.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if user.confirmed?
checks here if the admin user is confirmed. Which they should be, right?