From 42bcb46926948a74031a17c0fe44894da7921009 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 23 May 2018 15:40:34 -0500 Subject: [PATCH 1/3] remove unneeded javascript asset --- app/assets/javascripts/onboard.js | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 app/assets/javascripts/onboard.js diff --git a/app/assets/javascripts/onboard.js b/app/assets/javascripts/onboard.js deleted file mode 100644 index dee720fa..00000000 --- a/app/assets/javascripts/onboard.js +++ /dev/null @@ -1,2 +0,0 @@ -// Place all the behaviors and hooks related to the matching controller here. -// All this logic will automatically be available in application.js. From 2a70846a9ddbe346d45b380da6b3e5d09e3ab7a1 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 23 May 2018 15:42:07 -0500 Subject: [PATCH 2/3] Front now redirects to an appropriate page --- app/controllers/front_controller.rb | 11 ++--- spec/controllers/front_spec.rb | 42 +++++++++++++++++++ .../support/shared_user_context.rb | 2 + 3 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 spec/controllers/front_spec.rb diff --git a/app/controllers/front_controller.rb b/app/controllers/front_controller.rb index 631e559c..e43cf7b7 100755 --- a/app/controllers/front_controller.rb +++ b/app/controllers/front_controller.rb @@ -1,17 +1,14 @@ # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later class FrontController < ApplicationController - - - def index - flash.keep - if current_role?([:nonprofit_admin,:nonprofit_associate]) + if !Nonprofit.any? + redirect_to onboard_path + elsif current_role?([:nonprofit_admin,:nonprofit_associate]) redirect_to NonprofitPath.dashboard(administered_nonprofit) elsif current_user redirect_to '/profiles/' + current_user.profile.id.to_s else - respond_to { |format| format.html } + redirect_to new_user_session_path end end - end diff --git a/spec/controllers/front_spec.rb b/spec/controllers/front_spec.rb new file mode 100644 index 00000000..b64291c6 --- /dev/null +++ b/spec/controllers/front_spec.rb @@ -0,0 +1,42 @@ +# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later +require 'rails_helper' +require 'controllers/support/shared_user_context' + +describe FrontController, :type => :controller do + describe 'authorization' do + include_context :shared_user_context + describe 'accept all' do + describe 'index' do + include_context :open_to_all, :get, :index + end + end + end + + it 'index redirects to onboard with no non-profits' do + get( :index) + expect(response).to redirect_to onboard_url + end + + describe 'have nonprofit info' do + include_context :shared_user_context + it 'redirect to nonprofit admin' do + sign_in user_as_np_admin + get(:index) + expect(response).to redirect_to NonprofitPath.dashboard(nonprofit) + end + it 'redirect to nonprofit admin' do + sign_in user_as_np_associate + get(:index) + expect(response).to redirect_to NonprofitPath.dashboard(nonprofit) + end + + it 'redirect to general user' do + nonprofit + unauth_user.create_profile + sign_in unauth_user + get(:index) + expect(response).to redirect_to profile_url(unauth_user.profile.id) + end + + end +end \ No newline at end of file diff --git a/spec/controllers/support/shared_user_context.rb b/spec/controllers/support/shared_user_context.rb index 1ce177e3..7517f4a1 100644 --- a/spec/controllers/support/shared_user_context.rb +++ b/spec/controllers/support/shared_user_context.rb @@ -105,6 +105,8 @@ RSpec.shared_context :shared_user_context do expect(response.status).to eq 302 end + alias_method :redirects_to, :reject + def fix_args( *args) replacements = { __our_np: nonprofit.id, From c1deb8be04792c14fd3c957bb57fb8194176a2d0 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Wed, 23 May 2018 15:43:49 -0500 Subject: [PATCH 3/3] Remove cruft --- app/assets/stylesheets/front/page.css.scss | 17 ----------------- app/views/front/index.html.erb | 22 ---------------------- client/js/front/page.js | 2 -- 3 files changed, 41 deletions(-) delete mode 100755 app/assets/stylesheets/front/page.css.scss delete mode 100755 app/views/front/index.html.erb delete mode 100644 client/js/front/page.js diff --git a/app/assets/stylesheets/front/page.css.scss b/app/assets/stylesheets/front/page.css.scss deleted file mode 100755 index 62cca345..00000000 --- a/app/assets/stylesheets/front/page.css.scss +++ /dev/null @@ -1,17 +0,0 @@ -/* License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later */ -@import 'mixins'; - - -body { padding: 0; } - -@media screen and (max-width: 700px) { - .overview { padding: 10px; } - .overview-col { - width: 100%; - display: block; - padding: 0; - margin-bottom: 10px; - } - .overview-col:last-of-type { margin: 0; } -} - diff --git a/app/views/front/index.html.erb b/app/views/front/index.html.erb deleted file mode 100755 index 51bbd547..00000000 --- a/app/views/front/index.html.erb +++ /dev/null @@ -1,22 +0,0 @@ -<%- # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -%> - - - -<% content_for :head do %> - -<% end %> - -<% content_for :stylesheets do %> - <%= stylesheet_link_tag 'front/page' %> -<% end %> - -<% content_for :javascripts do %> - <%= IncludeAsset.js('/client/js/front/page.js') %> -<% end %> - - -
- <%= render 'layouts/top_nav' %> - -
- diff --git a/client/js/front/page.js b/client/js/front/page.js deleted file mode 100644 index 505c51bf..00000000 --- a/client/js/front/page.js +++ /dev/null @@ -1,2 +0,0 @@ -// License: LGPL-3.0-or-later -require('../common/onboard') \ No newline at end of file