Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RUBY-3433: Tech Debt : remove devise and cancancan gems + remove front-office users from wcr engine #1583

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
146bbf1
[RUBY-3433] Remove devise gem and dependencies + refactor tests to ac…
brujeo Oct 17, 2024
9ac26c6
[RUBY-3433] moving TransientRegistrationsController from engine to ba…
brujeo Oct 17, 2024
24a809d
[RUBY-3433] removing cancacan gem and permission check code associate…
brujeo Oct 21, 2024
3830b5f
[RUBY-3433] Moving email tracking analyics tests to back-office
brujeo Oct 21, 2024
6eb5ceb
[RUBY-3433] refactoring prepare_for_payment method not to require use…
brujeo Oct 21, 2024
ab49dfc
[RUBY-3433] refactoring FlowPermissionChecksService not to require us…
brujeo Oct 21, 2024
ce8c378
[RUBY-3433] refactoring front-office related services not to require …
brujeo Oct 21, 2024
37b033d
[RUBY-3433] removing front-office user model
brujeo Oct 21, 2024
e8de27e
[RUBY-3433] moving conviction sign-offs related tests to back-office
brujeo Oct 21, 2024
c77edb0
[RUBY-3433] refactoring permission check not to check on front-office…
brujeo Oct 21, 2024
aad4882
[RUBY-3433] refactoring CertificateGeneratorService to make requester…
brujeo Oct 21, 2024
ae08c0b
[RUBY-3433] Refactor permission check to make user parameter optional
brujeo Oct 22, 2024
258a943
[RUBY-3433] updating readme
brujeo Oct 22, 2024
2d00018
Merge branch 'main' into feature/RUBY-3433-wcr-tech-debt-remove-the-d…
brujeo Oct 22, 2024
ce16eab
[RUBY-3433] Refactor payment setup in controllers to include current …
brujeo Oct 23, 2024
77c7bf9
[RUBY-3433] code styling adjustments
brujeo Oct 23, 2024
336c7cf
[RUBY-3433] adding nocov tags to the code that does not get executed
brujeo Oct 23, 2024
3f430d2
[RUBY-3433] Refactor current_user method in application_controller.rb
brujeo Oct 23, 2024
c71c3a4
[RUBY-3433] deleting redundant user factory
brujeo Oct 24, 2024
35bcadd
[RUBY-3433] removing redundant method
brujeo Oct 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ gem "defra_ruby_template", "~> 5.0"

gem "mongo_session_store"

# Use CanCanCan for user roles and permissions
gem "cancancan", "~> 3.5.0"

# Use Devise for user authentication
gem "devise", "~> 4.9.2"

gem "matrix", "~> 0.4.2"

gem "secure_headers", "~> 6.5.0"
Expand Down
16 changes: 0 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@ GEM
async-pool (0.4.0)
async (>= 1.25)
base64 (0.2.0)
bcrypt (3.1.20)
bindex (0.8.1)
bson (4.15.0)
builder (3.3.0)
byebug (11.1.3)
cancancan (3.5.0)
coderay (1.1.3)
concurrent-ruby (1.3.4)
console (1.23.2)
Expand Down Expand Up @@ -163,12 +161,6 @@ GEM
rest-client (~> 2.0)
uk_postcode
validates_email_format_of
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.0)
docile (1.4.0)
domain_name (0.6.20231109)
Expand Down Expand Up @@ -274,7 +266,6 @@ GEM
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
orm_adapter (0.5.0)
os_map_ref (0.5.0)
parallel (1.23.0)
parser (3.2.2.4)
Expand Down Expand Up @@ -335,9 +326,6 @@ GEM
rake (13.2.1)
rbtree3 (0.7.1)
regexp_parser (2.8.2)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rest-client (2.1.0)
http-accept (>= 1.7.0, < 2.0)
http-cookie (>= 1.0.2, < 2.0)
Expand Down Expand Up @@ -443,8 +431,6 @@ GEM
validates_email_format_of (1.7.2)
i18n
vcr (6.2.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -465,11 +451,9 @@ PLATFORMS
ruby

DEPENDENCIES
cancancan (~> 3.5.0)
database_cleaner-mongoid (~> 2.0.1)
defra_ruby_style (~> 0.3.0)
defra_ruby_template (~> 5.0)
devise (~> 4.9.2)
dotenv-rails (~> 2.8.1)
factory_bot_rails (~> 6.2.0)
faker (~> 3.2.0)
Expand Down
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ Make sure you already have:
- [Bundler](http://bundler.io/) – for installing Ruby gems
- MongoDb 3.6

The engine also expects these gems to be installed in the application in which it is mounted:

- [Devise](https://github.com/plataformatec/devise/) >= 4.4.3
- [CanCanCan](https://github.com/CanCanCommunity/cancancan) ~> 1.10

And for a User model to be in place. See the [dummy testing app](https://github.com/DEFRA/waste-carriers-engine/tree/master/spec/dummy) for an example of how this might be implemented.

## Mounting the engine

Add the engine to your Gemfile:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ class ApplicationController < ActionController::Base
redirect_to page_path("system_error")
end

def current_user
return unless defined?(super)

# :nocov:
super
# :nocov:
end

protected

def record_user_journey
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion app/models/waste_carriers_engine/renewing_registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def pending_payment?
renewal_application_submitted? && super
end

def prepare_for_payment(mode, user)
def prepare_for_payment(mode, user = nil)
BuildRenewalFinanceDetailsService.run(transient_registration: self, payment_method: mode, user:)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class BaseRegistrationPermissionChecksService < BaseService

attr_reader :transient_registration, :user, :permission_check_result

def run(transient_registration:, user:)
def run(transient_registration:, user: nil)
@transient_registration = transient_registration
@user = user
@permission_check_result = PermissionChecksResult.new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MissingFlowPermissionChecksService < StandardError; end

attr_reader :transient_registration, :user

def run(transient_registration:, user:)
def run(transient_registration:, user: nil)
@transient_registration = transient_registration
@user = user

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
module WasteCarriersEngine
class GovpayPaymentService

def initialize(transient_registration, order, current_user)
def initialize(transient_registration, order, current_user = nil)
@transient_registration = transient_registration
@order = order
@current_user = current_user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def all_checks_pass?
end

def user_has_permission?
# user permission checks apply only to the back office
return true unless WasteCarriersEngine.configuration.host_is_back_office?

return true if transient_registration.from_magic_link
return true if can?(:update, transient_registration)

Expand Down
7 changes: 0 additions & 7 deletions app/views/devise/mailer/email_changed.html.erb

This file was deleted.

3 changes: 0 additions & 3 deletions app/views/devise/mailer/password_change.html.erb

This file was deleted.

8 changes: 0 additions & 8 deletions app/views/devise/mailer/reset_password_instructions.html.erb

This file was deleted.

7 changes: 0 additions & 7 deletions app/views/devise/mailer/unlock_instructions.html.erb

This file was deleted.

45 changes: 0 additions & 45 deletions app/views/devise/passwords/edit.html.erb

This file was deleted.

22 changes: 0 additions & 22 deletions app/views/devise/passwords/new.html.erb

This file was deleted.

32 changes: 0 additions & 32 deletions app/views/devise/sessions/new.html.erb

This file was deleted.

35 changes: 0 additions & 35 deletions app/views/devise/shared/_links.html.erb

This file was deleted.

22 changes: 0 additions & 22 deletions app/views/devise/unlocks/new.html.erb

This file was deleted.

15 changes: 15 additions & 0 deletions config/locales/activemodel.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n

en:
activemodel:
errors:
models:
waste_carriers_engine/renewal_lookup_validatable:
already_confirmed: "Email was already confirmed, please try signing in"
confirmation_period_expired: "Email needs to be confirmed within %{period}, please request a new one"
expired: "Password reset token has expired, please request a new one"
not_found: "Password reset token not found"
not_locked: "Account was not locked"
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"
Loading
Loading