Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gem 'saml_idp', git: 'https://github.com/18F/saml_idp.git', tag: 'v0.7.0-18f'
gem 'sass-rails', '~> 5.0'
gem 'savon'
gem 'scrypt'
gem 'secure_headers', '~> 3.0'
gem 'secure_headers', '~> 6.0'
gem 'sidekiq'
gem 'simple_form'
gem 'sinatra', require: false
Expand Down
6 changes: 2 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,7 @@ GEM
wasabi (~> 3.4)
scrypt (3.0.5)
ffi-compiler (>= 1.0, < 2.0)
secure_headers (3.7.3)
useragent
secure_headers (6.0.0)
selenium-webdriver (3.11.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
Expand Down Expand Up @@ -626,7 +625,6 @@ GEM
unicode-display_width (1.3.0)
uniform_notifier (1.11.0)
user_agent_parser (2.4.1)
useragent (0.16.8)
uuid (2.3.9)
macaddr (~> 1.0)
valid_email (0.1.0)
Expand Down Expand Up @@ -754,7 +752,7 @@ DEPENDENCIES
sass-rails (~> 5.0)
savon
scrypt
secure_headers (~> 3.0)
secure_headers (~> 6.0)
shoulda-matchers (~> 3.0)
sidekiq
simple_form
Expand Down
5 changes: 1 addition & 4 deletions app/decorators/service_provider_session_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
class ServiceProviderSessionDecorator
include Rails.application.routes.url_helpers
include LocaleHelper

DEFAULT_LOGO = 'generic.svg'.freeze

SP_ALERTS = {
Expand Down Expand Up @@ -97,7 +94,7 @@ def sp_return_url
end

def cancel_link_url
sign_up_start_url(request_id: sp_session[:request_id], locale: locale_url_param)
view_context.sign_up_start_url(request_id: sp_session[:request_id])
end

def sp_alert?
Expand Down
11 changes: 8 additions & 3 deletions app/decorators/session_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class SessionDecorator
include Rails.application.routes.url_helpers
include LocaleHelper
def initialize(view_context: nil)
@view_context = view_context
end

def return_to_service_provider_partial
'shared/null'
Expand Down Expand Up @@ -31,7 +32,7 @@ def idv_hardfail4_partial
end

def cancel_link_url
root_url(locale: locale_url_param)
view_context.root_url
end

def sp_name; end
Expand All @@ -51,4 +52,8 @@ def sp_alert?; end
def sp_alert_name; end

def sp_alert_learn_more; end

private

attr_reader :view_context
end
2 changes: 1 addition & 1 deletion app/services/decorated_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def call
service_provider_request: service_provider_request
)
else
SessionDecorator.new
SessionDecorator.new(view_context: view_context)
end
end

Expand Down
16 changes: 6 additions & 10 deletions spec/decorators/service_provider_session_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,14 @@
)
end

it 'returns sign_up_start_url with the request_id as a param' do
expect(decorator.cancel_link_url).
to eq 'http://www.example.com/sign_up/start?request_id=foo'
before do
allow(view_context).to receive(:sign_up_start_url).
and_return('https://www.example.com/sign_up/start')
end

context 'in another language' do
before { I18n.locale = :fr }

it 'keeps the language' do
expect(decorator.cancel_link_url).
to eq 'http://www.example.com/fr/sign_up/start?request_id=foo'
end
it 'returns view_context.sign_up_start_url' do
expect(decorator.cancel_link_url).
to eq 'https://www.example.com/sign_up/start'
end
end
end
8 changes: 6 additions & 2 deletions spec/decorators/session_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@
end

describe '#cancel_link_url' do
it 'returns root url' do
expect(subject.cancel_link_url).to eq 'http://www.example.com/'
it 'returns view_context.root url' do
view_context = ActionController::Base.new.view_context
allow(view_context).to receive(:root_url).and_return('http://www.example.com')
decorator = SessionDecorator.new(view_context: view_context)

expect(decorator.cancel_link_url).to eq 'http://www.example.com'
end
end
end
2 changes: 1 addition & 1 deletion spec/features/users/sign_up_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
click_on t('links.cancel')
click_on t('sign_up.buttons.cancel')

expect(page).to have_current_path(sign_up_start_path)
expect(page).to have_current_path(sign_up_start_path(request_id: '123'))
expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/features/session_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def begin_sign_up_with_sp_and_loa(loa3:)
Warden.on_next_request do |proxy|
session = proxy.env['rack.session']
sp = ServiceProvider.from_issuer('http://localhost:3000')
session[:sp] = { loa3: loa3, issuer: sp.issuer }
session[:sp] = { loa3: loa3, issuer: sp.issuer, request_id: '123' }
end

visit account_path
Expand Down
3 changes: 3 additions & 0 deletions spec/views/devise/passwords/new.html.slim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
return_to_sp_url: 'www.awesomeness.com'
)
view_context = ActionController::Base.new.view_context
allow(view_context).to receive(:sign_up_start_url).
and_return('https://www.example.com/sign_up/start')

@decorated_session = DecoratedSession.new(
sp: @sp,
view_context: view_context,
Expand Down
1 change: 1 addition & 0 deletions spec/views/sign_up/registrations/new.html.slim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
sp: nil, view_context: view_context, sp_session: {}, service_provider_request: nil
).call
allow(view).to receive(:decorated_session).and_return(@decorated_session)
allow(view_context).to receive(:root_url).and_return('http://www.example.com')
end

it 'has a localized title' do
Expand Down