-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test route to avoid the shadow root/having to render the global n…
…av (#70) This PR adds a login page to use in testing to avoid having to render the rpf-global-nav in tests that don't need JS. # What's changed * Adds a page at `/rpi_auth/test` which shows a login and sign-up button that can be used in test scenarios * Adds a `log_in(user:)` and `stub_auth_for(user:)` methods that we've replicated in a lot of places. * Adds capybara to the development deps, and updated the gemfiles * Sets the `rubygems` version during CI because one of the Gems doesn't build with the older version of Rubygems that ships with Ruby 2.7
- Loading branch information
Showing
21 changed files
with
673 additions
and
386 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,46 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2021-09-14 13:25:06 UTC using RuboCop version 1.20.0. | ||
# on 2024-07-02 19:48:59 UTC using RuboCop version 1.64.1. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
# Offense count: 6 | ||
# Configuration parameters: CountAsOne. | ||
RSpec/ExampleLength: | ||
Max: 8 | ||
# Offense count: 11 | ||
# Configuration parameters: EnforcedStyle, AllowedGems, Include. | ||
# SupportedStyles: Gemfile, gems.rb, gemspec | ||
# Include: **/*.gemspec, **/Gemfile, **/gems.rb | ||
Gemspec/DevelopmentDependencies: | ||
Exclude: | ||
- 'rpi_auth.gemspec' | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. | ||
# Include: **/*_spec*rb*, **/spec/**/* | ||
RSpec/FilePath: | ||
Exclude: | ||
- 'spec/rpi_auth/models/authenticatable_spec.rb' | ||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. | ||
Metrics/AbcSize: | ||
Max: 23 | ||
|
||
# Offense count: 7 | ||
RSpec/MultipleExpectations: | ||
# Configuration parameters: CountAsOne. | ||
RSpec/ExampleLength: | ||
Max: 8 | ||
|
||
# Offense count: 1 | ||
RSpec/NestedGroups: | ||
# Offense count: 20 | ||
RSpec/MultipleExpectations: | ||
Max: 4 | ||
|
||
# Offense count: 8 | ||
# Configuration parameters: AllowSubject. | ||
RSpec/MultipleMemoizedHelpers: | ||
Max: 6 | ||
|
||
# Offense count: 10 | ||
# Configuration parameters: AllowedGroups. | ||
RSpec/NestedGroups: | ||
Max: 5 | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. | ||
# Include: **/*_spec.rb | ||
RSpec/SpecFilePathFormat: | ||
Exclude: | ||
- 'spec/rpi_auth/models/authenticatable_spec.rb' |
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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rpi_auth/controllers/current_user' | ||
|
||
module RpiAuth | ||
class TestController < ActionController::Base | ||
include RpiAuth::Controllers::CurrentUser | ||
include Rails.application.routes.url_helpers | ||
|
||
layout false | ||
|
||
def show | ||
render locals: { login_params: login_params, logout_params: logout_params } | ||
end | ||
|
||
private | ||
|
||
def login_params | ||
params.permit(:returnTo) | ||
end | ||
|
||
alias logout_params login_params | ||
end | ||
end |
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,21 @@ | ||
<!doctype html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<%= stylesheet_link_tag 'https://static.raspberrypi.org/styles/design-system-core/releases/v1.1.0/design-system-core.css' %> | ||
<%= csp_meta_tag %> | ||
</head> | ||
<body> | ||
<div class='login-box'> | ||
<% if current_user.present? %> | ||
<p>Log out of your Raspberry Pi account</p> | ||
<p>Logged in as <%= current_user.user_id %></p> | ||
<%= link_to 'Log out', rpi_auth_logout_path(params: logout_params), class: "rpf-button" %> | ||
<% else %> | ||
<p>Log in with your Raspberry Pi account</p> | ||
<%= button_to 'Log in', rpi_auth_login_path, params: login_params, class: "rpf-button" %> | ||
<p>Sign up for a Raspberry Pi account</p> | ||
<%= button_to 'Sign up', rpi_auth_signup_path, params: login_params, class: "rpf-button" %> | ||
<% end %> | ||
</div> | ||
</body> | ||
</html> |
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
Oops, something went wrong.