diff --git a/app/cells/application/index.slim b/app/cells/application/index.slim index 77aed3bd..3db52e0a 100644 --- a/app/cells/application/index.slim +++ b/app/cells/application/index.slim @@ -14,4 +14,4 @@ div class=[muted] - elsif options[:current_user].subscription_version == 2 = link_to 'Reveal & Apply ❯', reveals_path(fund: options[:fund]), method: :post, class: 'blue' - else - = link_to status[:link_text] || 'Apply ❯', proposal_fund_path(model, options[:fund]), class: 'blue' \ No newline at end of file + = link_to status[:link_text] || 'Apply ❯', fund_path(options[:fund], model), class: 'blue' \ No newline at end of file diff --git a/app/cells/breadcrumb_cell.rb b/app/cells/breadcrumb_cell.rb index 69140065..0de1b2d0 100644 --- a/app/cells/breadcrumb_cell.rb +++ b/app/cells/breadcrumb_cell.rb @@ -1,6 +1,7 @@ class BreadcrumbCell < Cell::ViewModel def show return unless model.is_a?(Hash) && model.present? + model.delete_if { |k, _v| k.nil? } render end diff --git a/app/cells/eligibility/quiz.slim b/app/cells/eligibility/quiz.slim index 56d05e02..024c4c36 100644 --- a/app/cells/eligibility/quiz.slim +++ b/app/cells/eligibility/quiz.slim @@ -2,7 +2,7 @@ h3.mb10 Quiz .uk-form.uk-form-stacked.uk-clearfix - if model.present? - = simple_form_for :check, url: eligibility_proposal_fund_path(model, fund), method: :patch do |f| + = simple_form_for :check, url: eligibility_path(fund, model), method: :patch do |f| - if model.recipient.incomplete_first_proposal? diff --git a/app/cells/filter/show.slim b/app/cells/filter/show.slim index 89efd0d3..7a156f22 100644 --- a/app/cells/filter/show.slim +++ b/app/cells/filter/show.slim @@ -10,4 +10,4 @@ form#filter.flex.flex-wrap .md.inline-block | Grant duration: - = select 'duration', [["all", "All"], ["proposal", "Your proposal (#{@options[:funding_duration]} months)"], ["up-to-2y", "Up to 2 years"], ["2y-plus", "More than 2 years"]] + = select 'duration', [["all", "All"], proposal_duration, ["up-to-2y", "Up to 2 years"], ["2y-plus", "More than 2 years"]].compact diff --git a/app/cells/filter_cell.rb b/app/cells/filter_cell.rb index 1ba065a5..24524f98 100644 --- a/app/cells/filter_cell.rb +++ b/app/cells/filter_cell.rb @@ -14,11 +14,14 @@ def selected?(id, value) def select(id, options) tag.select id: id do options.map do |opt| - unless opt.kind_of?(Array) - opt = [opt, opt.humanize.capitalize] - end + opt = [opt, opt.humanize.capitalize] unless opt.is_a?(Array) tag.option(opt[1], value: url_encode(opt[0]), selected: selected?(id, opt[0])) end.reduce(:+) end end + + def proposal_duration + ['proposal', "Your proposal (#{options[:funding_duration]} months)"] if + options[:funding_duration] + end end diff --git a/app/cells/footer_themes/show.slim b/app/cells/footer_themes/show.slim index 4051a131..e489cf25 100644 --- a/app/cells/footer_themes/show.slim +++ b/app/cells/footer_themes/show.slim @@ -1,7 +1,4 @@ ul - themes.each do |theme| li.mb10 - - if proposal.present? - = link_to theme.name, theme_proposal_funds_path(proposal, theme), class: 'slate' - - else - = link_to theme.name, public_funds_theme_path(theme), class: 'slate' + = link_to theme.name, theme_path(theme, proposal), class: 'slate' diff --git a/app/cells/fund_insight/title.slim b/app/cells/fund_insight/title.slim index 99c788a7..af3d042d 100644 --- a/app/cells/fund_insight/title.slim +++ b/app/cells/fund_insight/title.slim @@ -1,3 +1,3 @@ h3.uk-margin-top - => link_to model.title, proposal_fund_path(proposal, model), class: 'yellow' + => link_to model.title, fund_path(model, proposal), class: 'yellow' span.year.muted= model.subtitle diff --git a/app/cells/fund_insight_cell.rb b/app/cells/fund_insight_cell.rb index d3152572..661e6c8b 100644 --- a/app/cells/fund_insight_cell.rb +++ b/app/cells/fund_insight_cell.rb @@ -31,7 +31,11 @@ def title def themes model.themes.map do |theme| - link_to(theme.name, theme_path(theme), class: "tag #{theme.classes}") + link_to( + theme.name, + theme_path(theme, options[:proposal]), + class: "tag #{theme.classes}" + ) end.join end @@ -89,14 +93,6 @@ def title_name funder.funds.size > 1 ? [name, funder.name] : [funder.name, name] end - def theme_path(theme) - if options[:proposal] - theme_proposal_funds_path(options[:proposal], theme) - else - public_funds_theme_path(theme) - end - end - def grant_types_message costs = model.permitted_costs.reject(&:zero?) .map { |c| FUNDING_TYPES[c][0].split.first.downcase } diff --git a/app/cells/new_proposal_links/dashboard.slim b/app/cells/new_proposal_links/dashboard.slim index 260d1ec7..499dbcf9 100644 --- a/app/cells/new_proposal_links/dashboard.slim +++ b/app/cells/new_proposal_links/dashboard.slim @@ -1,3 +1,3 @@ .fs16.center.py15.border-top.border-lightest-gray - = link_to 'Funds', proposal_funds_path(model), class: 'red px15' + = link_to 'Funds', funds_path(model), class: 'red px15' = link_to 'Edit', edit_proposal_path(model), class: 'blue px15' diff --git a/app/cells/progress/apply.rb b/app/cells/progress/apply.rb index 1e6f525c..87597fd4 100644 --- a/app/cells/progress/apply.rb +++ b/app/cells/progress/apply.rb @@ -17,7 +17,7 @@ def message when ELIGIBLE link_to( 'Apply ❯', - url_helpers.apply_proposal_fund_path(@proposal, @fund), + url_helpers.apply_path(@fund, @proposal), class: 'fs15 btn white bg-blue shadow' ) else diff --git a/app/cells/suitability/index.slim b/app/cells/suitability/index.slim index 0e2fa3d8..1b16c8d4 100644 --- a/app/cells/suitability/index.slim +++ b/app/cells/suitability/index.slim @@ -7,4 +7,4 @@ =< status[:status] - if status[:message] .mb5 = status[:message] -= link_to status[:link_text], proposal_fund_path(model, fund), class: 'blue' \ No newline at end of file += link_to status[:link_text], fund_path(fund, model), class: 'blue' \ No newline at end of file diff --git a/app/cells/suitability/quiz.slim b/app/cells/suitability/quiz.slim index cfe13fd2..e939ef0c 100644 --- a/app/cells/suitability/quiz.slim +++ b/app/cells/suitability/quiz.slim @@ -3,7 +3,7 @@ h4.mb10 .uk-form.uk-form-stacked.uk-clearfix - if model.present? - = simple_form_for :check, url: eligibility_proposal_fund_path(model, fund), method: :patch do |f| + = simple_form_for :check, url: eligibility_path(fund, model), method: :patch do |f| - if model.recipient.incomplete_first_proposal? diff --git a/app/cells/v2_navbar/show.slim b/app/cells/v2_navbar/show.slim index 43994867..26bcc3c4 100644 --- a/app/cells/v2_navbar/show.slim +++ b/app/cells/v2_navbar/show.slim @@ -8,5 +8,5 @@ = link_to 'Sign out', logout_path, class: "#{type} ml35" - else = link_to 'About', about_path, class: "#{type} ml35" - = link_to 'Funds', public_funds_path, class: "#{type} ml35" + = link_to 'Funds', funds_path, class: "#{type} ml35" = link_to 'Sign in', sign_in_path, class: "#{type} ml35" diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7c7b8629..6cb6e429 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -53,7 +53,7 @@ def load_last_proposal @proposal = if params[:proposal_id] @recipient.proposals.find_by(id: params[:proposal_id]) else - @recipient.proposals.last + @recipient.proposals.last # TODO: remove end end @@ -99,10 +99,10 @@ def start_path return edit_signup_recipient_path(@recipient) unless @recipient.valid? # NOTE: legacy return new_signup_proposal_path unless @proposal return new_signup_proposal_path if @proposal.initial? # NOTE: legacy - proposal_funds_path(@proposal) + funds_path(@proposal) end def ensure_not_signed_up - redirect_to proposal_funds_path(@proposal) if signed_up? + redirect_to funds_path(@proposal) if signed_up? end end diff --git a/app/controllers/eligibilities_controller.rb b/app/controllers/eligibilities_controller.rb index 303ff4d0..ef6511c0 100644 --- a/app/controllers/eligibilities_controller.rb +++ b/app/controllers/eligibilities_controller.rb @@ -16,7 +16,7 @@ def create @recipient.update_funds_checked!(@proposal.eligibility) Assessment.analyse_and_update!(Fund.active, @proposal) # TODO: refactor track_quiz_completion(@fund) - redirect_to proposal_fund_path(@proposal, @fund) + redirect_to fund_path(@fund, @proposal) end end diff --git a/app/controllers/enquiries_controller.rb b/app/controllers/enquiries_controller.rb index 59405935..b3978a5f 100644 --- a/app/controllers/enquiries_controller.rb +++ b/app/controllers/enquiries_controller.rb @@ -23,10 +23,6 @@ def authenticate end def user_not_authorised - if @current_user.subscription_version == 2 - redirect_to account_upgrade_path(@recipient) - else - redirect_to proposal_fund_path(@proposal, @fund) - end + redirect_to account_upgrade_path(@recipient) end end diff --git a/app/controllers/feedback_controller.rb b/app/controllers/feedback_controller.rb index af76be90..9abadea4 100644 --- a/app/controllers/feedback_controller.rb +++ b/app/controllers/feedback_controller.rb @@ -7,7 +7,7 @@ def new @fund = Fund.find_by(slug: @redirect_to_funder) # TODO: refactor return unless current_user.feedbacks.count.positive? - redirect_to proposal_funds_path(@proposal), + redirect_to funds_path(@proposal), alert: "It looks like you've already provided feedback" end @@ -17,7 +17,7 @@ def create if @feedback.save session.delete(:redirect_to_funder) - redirect_to proposal_fund_path(@proposal, @fund), + redirect_to fund_path(@fund, @proposal), notice: "You're a star! Thanks for the feedback." else render :new @@ -34,7 +34,7 @@ def update # TODO: depreceted if @feedback.update_attributes(params.require(:feedback).permit(:price)) flash[:notice] = 'Thanks for the feedback!' redirect_to session.delete(:return_to) || - proposal_funds_path(@proposal) + funds_path(@proposal) else render :edit end diff --git a/app/controllers/funds_controller.rb b/app/controllers/funds_controller.rb index 3be89821..b1ab507a 100644 --- a/app/controllers/funds_controller.rb +++ b/app/controllers/funds_controller.rb @@ -1,5 +1,5 @@ class FundsController < ApplicationController - before_action :ensure_logged_in, :update_legacy_suitability, except: :sources + before_action :update_legacy_suitability, except: :sources before_action :load_fund, only: %i[hidden show] def show @@ -9,7 +9,7 @@ def show end def index - update_analysis(query) + update_analysis(query) if @proposal @funds = query.page(params[:page]) # TODO: refactor @fund_count = query.size @@ -19,25 +19,21 @@ def index def themed @theme = Theme.find_by(slug: params[:theme]) - redirect_to root_path, alert: 'Not found' unless @theme + redirect_to funds_path(@proposal), alert: 'Not found' unless @theme @funds = themed_query.page(params[:page]) @fund_count = themed_query.size # TODO: refactor end def hidden return redirect_to root_path unless @fund - @assessment = @proposal.assessments.where(fund: @fund).first + @assessment = @proposal.assessments.where(fund: @fund).first if @proposal end private def user_not_authorised - if @current_user.subscription_version == 2 - return redirect_to root_path if @fund.nil? - redirect_to hidden_proposal_fund_path(@proposal, @fund) - else - redirect_to account_upgrade_path(@recipient) - end + return redirect_to funds_path(@proposal) if @fund.nil? + redirect_to hidden_path(@fund, @proposal) end def update_analysis(funds) @@ -50,7 +46,7 @@ def update_analysis(funds) end def update_legacy_suitability # TODO: depreceted - @proposal.update_legacy_suitability + @proposal&.update_legacy_suitability end def query @@ -69,6 +65,8 @@ def themed_query end def load_fund - @fund = Fund.includes(:funder).active.find_by_hashid(params[:id]) + @fund = Fund.includes(:funder) + .where("state = 'active' OR state = 'stub'") + .find_by_hashid(params[:id]) end end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index c2704aa8..94521106 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -19,7 +19,7 @@ def create if @proposal.save Assessment.analyse_and_update!(Fund.active, @proposal) @proposal.next_step! - redirect_to proposal_funds_path(@proposal) + redirect_to funds_path(@proposal) else render :new end @@ -44,20 +44,20 @@ def update fund = Fund.find_by_hashid(session.delete(:return_to)) format.js do if session[:return_to] - render js: "window.location.href = '#{proposal_fund_path(@proposal, fund)}'; + render js: "window.location.href = '#{fund_path(fund, @proposal)}'; $('button[type=submit]').prop('disabled', true) .removeAttr('data-disable-with');" else - render js: "window.location.href = '#{proposal_funds_path(@proposal)}'; + render js: "window.location.href = '#{funds_path(@proposal)}'; $('button[type=submit]').prop('disabled', true) .removeAttr('data-disable-with');" end end format.html do if session[:return_to] - redirect_to proposal_fund_path(@proposal, fund) + redirect_to fund_path(fund, @proposal) else - redirect_to proposal_funds_path(@proposal) + redirect_to funds_path(@proposal) end end else diff --git a/app/controllers/public_funds_controller.rb b/app/controllers/public_funds_controller.rb deleted file mode 100644 index ba2bb219..00000000 --- a/app/controllers/public_funds_controller.rb +++ /dev/null @@ -1,35 +0,0 @@ -class PublicFundsController < ApplicationController - before_action :ensure_logged_out - - def index - @funds = Fund.active.recent.includes(:funder).page(params[:page]) - end - - def show - return redirect_to public_funds_path unless public_fund?(params[:id]) - @fund = Fund.find_by_hashid(params[:id]) - return redirect_to public_funds_path unless @fund - @restrictions = @fund.restrictions.pluck(:category, :details) - end - - def themed - @theme = Theme.find_by(slug: params[:theme]) if params[:theme].present? - @funds = Fund.active - .includes(:funder, :themes) - .where(themes: { id: @theme }) - .page(params[:page]) - redirect_to public_funds_path, alert: 'Not found' if @funds.empty? - end - - private - - def ensure_logged_out - redirect_to root_path if logged_in? - end - - def public_fund?(id) - Fund.active.recent.limit(3).pluck(:id) - .map { |i| HASHID.encode(i) } - .include?(id) - end -end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 53845cb4..a55d869b 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -5,7 +5,7 @@ def create authorize :request fund = Fund.find_by_hashid(params[:fund]) Request.create(fund: fund, recipient: @recipient, message: params[:message]) - redirect_to proposal_fund_path(@proposal, fund) + redirect_to fund_path(fund, @proposal) end private diff --git a/app/controllers/reveals_controller.rb b/app/controllers/reveals_controller.rb index d65c5131..f206b9a6 100644 --- a/app/controllers/reveals_controller.rb +++ b/app/controllers/reveals_controller.rb @@ -6,7 +6,7 @@ def create fund = Fund.find_by_hashid(params[:fund]) @recipient.reveals << fund.slug @recipient.save - redirect_to proposal_fund_path(@proposal, params[:fund]) + redirect_to fund_path(fund, @proposal) end private diff --git a/app/controllers/signup_proposals_controller.rb b/app/controllers/signup_proposals_controller.rb index 5d07bef7..875425a4 100644 --- a/app/controllers/signup_proposals_controller.rb +++ b/app/controllers/signup_proposals_controller.rb @@ -23,7 +23,7 @@ def create if @proposal.save Assessment.analyse_and_update!(Fund.active, @proposal) @proposal.next_step! - redirect_to proposal_funds_path(@proposal) + redirect_to funds_path(@proposal) else render :new end @@ -45,9 +45,9 @@ def update def return_to_path if session[:return_to] - proposal_fund_path(@proposal, session.delete(:return_to)) + fund_path(session.delete(:return_to), @proposal) else - proposal_funds_path(@proposal) + funds_path(@proposal) end end diff --git a/app/policies/enquiry_policy.rb b/app/policies/enquiry_policy.rb index 6b0e00d1..19c07225 100644 --- a/app/policies/enquiry_policy.rb +++ b/app/policies/enquiry_policy.rb @@ -1,19 +1,10 @@ class EnquiryPolicy < ApplicationPolicy def create? - use_subscription_version(__method__) + assessment&.eligibility_status == ELIGIBLE ? _fund_policy_show? : false end private - def v1_create? # TODO: deprecated - return true if user.subscription_active? - _fund_policy_show? ? record.proposal.eligible?(record.fund.slug) : false - end - - def v2_create? - assessment&.eligibility_quiz == 1 ? _fund_policy_show? : false - end - def _fund_policy_show? FundPolicy.new(user, FundContext.new(record.fund, record.proposal)).show? end diff --git a/app/policies/fund_policy.rb b/app/policies/fund_policy.rb index 1ddb5418..753509bb 100644 --- a/app/policies/fund_policy.rb +++ b/app/policies/fund_policy.rb @@ -1,25 +1,9 @@ class FundPolicy < ApplicationPolicy def show? - use_subscription_version(__method__) + return false unless record.fund + return true if record.featured || record.stub? + return false unless record.proposal + return true if user.subscription_active? + user.reveals.include?(record.slug) end - - private - - def v1_show? - return false unless record.fund && record.proposal - return true if record.fund.featured || record.fund.stub? - return true if user.subscription_active? - record.proposal - .suitable_funds - .pluck(0) - .take(RECOMMENDATION_LIMIT) - .include?(record.fund.slug) - end - - def v2_show? - return false unless record.fund - return true if record.featured || record.stub? - return true if user.subscription_active? - user.reveals.include?(record.slug) - end end diff --git a/app/views/enquiries/new.html.haml b/app/views/enquiries/new.html.haml index ea5dc6f0..6c3f7a5b 100644 --- a/app/views/enquiries/new.html.haml +++ b/app/views/enquiries/new.html.haml @@ -2,7 +2,7 @@ %header = cell :v2_navbar, @current_user - = cell :breadcrumb, (@proposal.title? ? @proposal.title : 'Current proposal').upcase_first => nil, 'Funds' => proposal_funds_path(@proposal), @fund.funder.name => nil, @fund.name => proposal_fund_path(@proposal, @fund), 'Apply' => apply_proposal_fund_path(@proposal, @fund) + = cell :breadcrumb, (@proposal.title? ? @proposal.title : 'Current proposal').upcase_first => nil, 'Funds' => funds_path(@proposal), @fund.funder.name => nil, @fund.name => fund_path(@fund, @proposal), 'Apply' => apply_path(@fund, @proposal) :javascript mixpanel.track("View Apply Page", {"Fund": "#{@fund.name}"}); @@ -36,7 +36,7 @@ %section %p If you haven't already, be sure to explore our analysis of the - = link_to "#{@fund.short_name.strip}", proposal_fund_path(@proposal, @fund), class: 'blue' + = link_to "#{@fund.short_name.strip}", fund_path(@fund, @proposal), class: 'blue' fund, otherwise below are a few things to consider before you proceed. %hr.my40 @@ -50,7 +50,7 @@ - if @fund.open_call? = link_to "Apply to #{@fund.title} ❯", - apply_proposal_fund_path(@proposal, @fund), + apply_path(@fund, @proposal), method: :post, target: '_blank', 'data-uk-tooltip': "{pos:'top'}", @@ -61,7 +61,7 @@ .bold.caps.mb10.fs15 Unsolicited applications Please note this fund does not accept unsolicited applications. Please read the fund guidance for more information. = link_to "More information on #{@fund.name.strip}", - apply_proposal_fund_path(@proposal, @fund), + apply_path(@fund, @proposal), method: :post, target: '_blank', 'data-uk-tooltip': "{pos:'top'}", diff --git a/app/views/funds/_fund.haml b/app/views/funds/_fund.haml index 08593a86..15f95b11 100644 --- a/app/views/funds/_fund.haml +++ b/app/views/funds/_fund.haml @@ -3,7 +3,7 @@ .p20 .flex.justify-between .block - %h3.mb5= link_to fund.name, proposal_fund_path(@proposal, fund) + %h3.mb5= link_to fund.name, fund_path(fund, @proposal) .fs15.night by = fund.funder.name @@ -15,7 +15,7 @@ .p20.border-top.border-silver %h6.bold.mb10= cell(:fund_insight, fund, proposal: @proposal).call(:summary) - .night= raw strip_tags(fund.description_html).truncate_words(30, omission: "... #{link_to 'more', proposal_fund_path(@proposal, fund)}") + .night= raw strip_tags(fund.description_html).truncate_words(30, omission: "... #{link_to 'more', fund_path(fund, @proposal)}") .truncate.mt10= cell(:fund_insight, fund, proposal: @proposal).call(:themes) diff --git a/app/views/funds/_fund_redacted.haml b/app/views/funds/_fund_redacted.haml index cd572ee2..9f408d33 100644 --- a/app/views/funds/_fund_redacted.haml +++ b/app/views/funds/_fund_redacted.haml @@ -2,19 +2,15 @@ .p20 .flex.justify-between .block - %h3.mb5= link_to 'Hidden fund', proposal_fund_path(@proposal, fund) + %h3.mb5= link_to 'Hidden fund', fund_path(fund, @proposal) .fs15.night by %span.grey.redacted= scramble_name fund.funder.name - - unless fund.eligibility_status - .block - .btn.fs15.slate.border-silver.disabled New - .p20.border-top.border-silver %h6.bold.mb10= cell(:fund_insight, fund, proposal: @proposal).call(:summary) - .night= raw redact(fund, :description, trim: 30, omission: "... #{link_to 'more', proposal_fund_path(@proposal, fund)}") + .night= raw redact(fund, :description, trim: 30, omission: "... #{link_to 'more', fund_path(fund, @proposal)}") .truncate.mt10= cell(:fund_insight, fund, proposal: @proposal).call(:themes) diff --git a/app/views/funds/_not_enough_data.html.haml b/app/views/funds/_not_enough_data.html.haml deleted file mode 100644 index 6a90a223..00000000 --- a/app/views/funds/_not_enough_data.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -.cta.tight - %strong Data unavailable - %br - = @fund.funder.name - does not publish this information in a way that we can use to provide you with analysis. We are working hard to change this, and remember you can - = link_to 'check your eligibility', proposal_fund_path(@proposal, @fund) - in the meantime. diff --git a/app/views/funds/_sidebar.haml b/app/views/funds/_sidebar.haml new file mode 100644 index 00000000..df68a3ca --- /dev/null +++ b/app/views/funds/_sidebar.haml @@ -0,0 +1,28 @@ +-# TODO: refactor +- if @proposal + .border.rounded.mb20.border-blue + .px10.py10.bg-blue + .fs15.lh20.caps.bold.white + Current Proposal + = render partial: 'proposals/card', locals: { proposal: @proposal, context: 'fund' } +- else + .bg-mint.white.px10.py15.rounded-top + %h3 Check your eligibility and suitability for funds in seconds. + %a.button-wide.button-bottom.white.bg-olive.caps.shadow{ href: root_path } Sign up + +- if @fund_stubs.present? + .mt40 + %h2.mb20.fs18 + Other potential leads + .fs12.lh16.mb20.slate + %p.mb10 + These are funds without the full set of data that + Beehive uses to check eligibility and suitability. + %p.mb10 + They have been selected at random. + %p + Follow the links below to request more information about these funds. + %ul + - @fund_stubs.each do |f| + %li.mb20.fs14.lh16 + = link_to f.funder.name, fund_path(f, @proposal), class: 'blue' \ No newline at end of file diff --git a/app/views/funds/hidden.haml b/app/views/funds/hidden.haml index 471146ac..e5336b2a 100644 --- a/app/views/funds/hidden.haml +++ b/app/views/funds/hidden.haml @@ -2,11 +2,12 @@ %header = cell :v2_navbar, @current_user - = cell :breadcrumb, (@proposal.title? ? @proposal.title : 'Current proposal').upcase_first => nil, 'Funds' => proposal_funds_path(@proposal), 'Hidden funder' => nil, 'Hidden fund' => proposal_fund_path(@proposal, @fund) + = cell(:breadcrumb, (@proposal ? 'Current proposal' : nil) => nil, 'Funds' => funds_path, 'Hidden funder' => nil, 'Hidden fund' => fund_path(@fund)) -:javascript - mixpanel.track('View Fund Page', { "Fund": "#{@fund.hashid}" }); - mixpanel.identify("#{@current_user.id}"); +- if @proposal # TODO: refactor + :javascript + mixpanel.track('View Fund Page', { "Fund": "#{@fund.hashid}" }); + mixpanel.identify("#{@current_user.id}"); %main .maxw1080.mx-auto.px40.mt40 diff --git a/app/views/funds/index.haml b/app/views/funds/index.haml index 93565fb4..240ff81d 100644 --- a/app/views/funds/index.haml +++ b/app/views/funds/index.haml @@ -2,17 +2,18 @@ %header = cell :v2_navbar, @current_user - = cell :breadcrumb, (@proposal.title? ? @proposal.title : 'Current proposal').upcase_first => nil,'Funds' => proposal_funds_path(@proposal) + = cell :breadcrumb, (@proposal ? 'Current proposal' : nil) => nil, 'Funds' => funds_path(@proposal) -:javascript - mixpanel.track('View Funds Page'); - mixpanel.identify("#{@current_user.id}"); - mixpanel.people.set({ - 'Fund Unlocks': "#{@recipient.funds_checked}", - }); +- if @proposal # TODO: refactor + :javascript + mixpanel.track('View Funds Page'); + mixpanel.identify("#{@current_user.id}"); + mixpanel.people.set({ + 'Fund Unlocks': "#{@recipient.funds_checked}", + }); - ga("send", "event", "Eligibility", "Eligible", "#{@proposal.eligible_funds.count}"); - ga("send", "event", "Eligibility", "Ineligible", "#{@proposal.ineligible_funds.count}"); + ga("send", "event", "Eligibility", "Eligible", "#{@proposal.eligible_funds.count}"); + ga("send", "event", "Eligibility", "Ineligible", "#{@proposal.ineligible_funds.count}"); / Google Code for View recommended funds :javascript @@ -29,38 +30,17 @@ %div{ style: "display:inline;" } %img{ alt: "", height: "1", src: "//www.googleadservices.com/pagead/conversion/937505505/?label=LPzOCKWprGMQ4eWEvwM&guid=ON&script=0", style: "border-style:none;", width: "1" } - %main + %h1= params[:pid] .maxw1080.mx-auto.px20.flex.flex-wrap %aside.perc25.md.px20.mb40.to-end-md - .border.rounded.mb20.border-blue - .px10.py10.bg-blue - .fs15.lh20.caps.bold.white - Current Proposal - = render partial: 'proposals/card', locals: { proposal: @proposal, context: 'fund' } - - - if @fund_stubs.present? - .mt40 - %h2.mb20.fs18 - Other potential leads - .fs12.lh16.mb20.slate - %p.mb10 - These are funds without the full set of data that - Beehive uses to check eligibility and suitability. - %p.mb10 - They have been selected at random. - %p - Follow the links below to request more information about these funds. - %ul - - @fund_stubs.each do |f| - %li.mb20.fs14.lh16 - = link_to f.funder.name, proposal_fund_path(@proposal, f), class: "blue" + = render partial: 'sidebar' %section.perc75.md.mb80.px20 %h1.mb20 Funds .mb30 - = cell :filter, params, funding_duration: @proposal.funding_duration + = cell :filter, params, funding_duration: @proposal&.funding_duration %small.slate = pluralize(@fund_count, 'fund') found diff --git a/app/views/funds/show.haml b/app/views/funds/show.haml index 319dc365..6d88072d 100644 --- a/app/views/funds/show.haml +++ b/app/views/funds/show.haml @@ -1,12 +1,13 @@ = content_for :title, @fund.title -:javascript - mixpanel.track('View Fund Page', { "Fund": "#{@fund.name}" }); - mixpanel.identify("#{@current_user.id}"); +- if @proposal # TODO: refactor + :javascript + mixpanel.track('View Fund Page', { "Fund": "#{@fund.name}" }); + mixpanel.identify("#{@current_user.id}"); %header = cell :v2_navbar, @current_user - = cell :breadcrumb, (@proposal.title? ? @proposal.title : 'Current proposal').upcase_first => nil, 'Funds' => proposal_funds_path(@proposal), @fund.funder.name => nil, @fund.name => proposal_fund_path(@proposal, @fund) + = cell :breadcrumb, (@proposal ? 'Current proposal' : nil) => nil, 'Funds' => funds_path(@proposal), @fund.funder.name => nil, @fund.name => fund_path(@fund, @proposal) %main .maxw1080.mx-auto.px40.mt40 diff --git a/app/views/funds/stub.haml b/app/views/funds/stub.haml index 4342947e..e3cb965c 100644 --- a/app/views/funds/stub.haml +++ b/app/views/funds/stub.haml @@ -1,12 +1,13 @@ = content_for :title, @fund.title -:javascript - mixpanel.track('View Fund Page', { "Fund": "#{@fund.name}" }); - mixpanel.identify("#{@current_user.id}"); +- if @proposal # TODO: refactor + :javascript + mixpanel.track('View Fund Page', { "Fund": "#{@fund.name}" }); + mixpanel.identify("#{@current_user.id}"); %header = cell :v2_navbar, @current_user - = cell :breadcrumb, (@proposal.title? ? @proposal.title : 'Current proposal').upcase_first => nil, 'Funds' => proposal_funds_path(@proposal), @fund.funder.name => proposal_fund_path(@proposal, @fund) + = cell :breadcrumb, (@proposal ? 'Current proposal' : nil) => nil, 'Funds' => funds_path(@proposal), @fund.funder.name => fund_path(@fund, @proposal) %main .maxw1080.mx-auto.px40.mt40 diff --git a/app/views/funds/themed.haml b/app/views/funds/themed.haml index 5fd6fb89..deb66514 100644 --- a/app/views/funds/themed.haml +++ b/app/views/funds/themed.haml @@ -2,22 +2,18 @@ %header = cell :v2_navbar, @current_user - = cell :breadcrumb, 'Funds' => proposal_funds_path(@proposal), @theme.name => theme_proposal_funds_path(@proposal, @theme) + = cell :breadcrumb, (@proposal ? 'Current proposal' : nil) => nil, 'Funds' => funds_path(@proposal), @theme.name => theme_path(@theme, @proposal) %main .maxw1080.mx-auto.px20.flex.flex-wrap %aside.perc25.md.px20.mb40.to-end-md - .border.rounded.mb20.border-blue - .px10.py10.bg-blue - .fs15.lh20.caps.bold.white - Current Proposal - = render partial: 'proposals/card', locals: { proposal: @proposal, context: 'fund' } + = render partial: 'sidebar' %section.perc75.md.mb80.px20 %h1.mb20=@theme.name .mb30 - = cell :filter, params, funding_duration: @proposal.funding_duration + = cell :filter, params, funding_duration: @proposal&.funding_duration %small.slate = pluralize(@fund_count, 'fund') found diff --git a/app/views/proposals/_card.html.haml b/app/views/proposals/_card.html.haml index 200018ea..9e83d9b9 100644 --- a/app/views/proposals/_card.html.haml +++ b/app/views/proposals/_card.html.haml @@ -12,7 +12,7 @@ funds checked - if proposal.complete? .fs20.mb40 - = link_to proposal.title.truncate_words(3), proposal_funds_path(proposal), class: 'black' + = link_to proposal.title.truncate_words(3), funds_path(proposal), class: 'black' .fs15.mb20 = number_to_currency(proposal.total_costs, unit: "£", precision: 0) · @@ -37,7 +37,7 @@ = link_to 'Change', proposals_path, class: 'blue px10' = link_to 'New', new_proposal_path, class: 'blue px10' - elsif proposal.registered? || proposal.complete? - = link_to 'Funds', proposal_funds_path(proposal), class: 'red px15' + = link_to 'Funds', funds_path(proposal), class: 'red px15' = link_to 'Edit', edit_proposal_path(proposal), class: 'blue px15' - else = link_to 'Complete', edit_signup_proposal_path(proposal), class: 'blue px15' diff --git a/app/views/proposals/index.html.haml b/app/views/proposals/index.html.haml index 88d7ad05..533698bd 100644 --- a/app/views/proposals/index.html.haml +++ b/app/views/proposals/index.html.haml @@ -27,6 +27,7 @@ = render partial: 'proposals/card', locals: { proposal: proposal, context: 'proposal' } .mb20.md + -# TODO: refactor - if @proposal.complete? - if @recipient.subscribed? = link_to "+ New proposal", new_proposal_path, class: 'button-wide bg-green white fs16 caps' diff --git a/app/views/public_funds/_fund_list.haml b/app/views/public_funds/_fund_list.haml deleted file mode 100644 index 4284786f..00000000 --- a/app/views/public_funds/_fund_list.haml +++ /dev/null @@ -1,38 +0,0 @@ -%main - .maxw1080.mx-auto.px20.flex.flex-wrap - %aside.perc25.md.px20.mb40 - .bg-mint.white.px10.py15.rounded-top - %h3 Check your eligibility and suitability for funds in seconds. - %a.button-wide.button-bottom.white.bg-olive.caps.shadow{ href: root_path } Sign up - - %section.perc75.md.mb80.px20 - %h1.mb30= name - - - @funds.each_with_index do |fund, i| - %article.mb40 - - - if i < funds_to_show && params[:page].to_i < 2 - .mb5 - = link_to fund.title, public_fund_path(fund), class: 'blue fs22 lh30' - .mb5.fs15.lh20.night - = fund.subtitle - %p.mb5.fs15.lh20 - = strip_tags fund.description_html.truncate_words(30) - - - else - .muted - .mb5.blue.fs22.lh30.redacted= scramble_name fund.name - .mb5.fs15.lh20.grey.redacted= scramble_name fund.funder.name - %p.mb5.fs15.lh20= raw redact(fund, :description, trim: 30) - - %p.fs14.lh18 - = cell(:fund_insight, fund).call(:themes) - - - if i == funds_to_show - 1 && params[:page].to_i < 2 - %a{ href: root_path } - .mb40.fs14.white.bg-darken-blue.circle.shadow.inline-block.py5.pr14.pl5.truncate - .fs12.bg-green.caps.bold.circle.inline-block.py3.px5 Preview - Sign in or create a free account to see more - - .center - = paginate @funds diff --git a/app/views/public_funds/index.haml b/app/views/public_funds/index.haml deleted file mode 100644 index d8e66c23..00000000 --- a/app/views/public_funds/index.haml +++ /dev/null @@ -1,7 +0,0 @@ -= content_for :title, 'Funds preview' - -%header - = cell :v2_navbar, @current_user - = cell :breadcrumb, 'Funds' => public_funds_path - -= render partial: 'fund_list', locals: { name: 'Funds', funds_to_show: 3 } diff --git a/app/views/public_funds/show.haml b/app/views/public_funds/show.haml deleted file mode 100644 index 9d2331bc..00000000 --- a/app/views/public_funds/show.haml +++ /dev/null @@ -1,76 +0,0 @@ -= content_for :title, "Preview #{@fund.title}" - -%header - = cell :v2_navbar, @current_user - = cell :breadcrumb, 'Funds' => public_funds_path, @fund.name => public_fund_path - -%main - .maxw1080.mx-auto.px40.mt40 - - .flex.flex-wrap.mb40 - %section.perc50.md.mb40.px20 - %h1.mb10= @fund.name - .mb30 - by - = @fund.funder.name - - .mb30.fs18.night.lh25= raw strip_tags @fund.description_html.truncate_words(30) - - %hr - %h6.my20.slate= cell(:fund_insight, @fund, proposal: @proposal).call(:summary) - %hr.mb30 - - = cell(:fund_insight, @fund, proposal: @proposal).call(:themes) - - %section.perc50.md - .mx-auto.shadow.border.rounded.border-silver.maxw420 - .p20.bg-light-blue - %h5.bold.mb10 Free, personal grant funding advice & eligibility checking. - = link_to 'Sign up', root_path, class: 'btn wide white bg-blue shadow' - - .border-top.border-silver - .flex.items-center.px20.py16.progress-item - .indicator.bot.mr20 - %h5.mr-auto Eligibility - %h6.bold.slate Pending - - .border-top.border-silver - .flex.items-center.px20.py16.progress-item - .indicator.top.bot.mr20 - %h5.mr-auto Suitability - %h6.bold.slate Pending - - .border-top.border-silver - .flex.items-center.px20.py16.progress-item - .indicator.top.mr20 - %h5.mr-auto Apply - %h6.bold.btn.fs15.slate.border-silver.disabled Apply ❯ - - %section.px20.mb80.md - %h2.mb20 Summary - - .mb20.markdown - = raw @fund.description_html - - - if @fund.period_end.present? && @fund.period_end > 3.years.ago - .mt30.night - .fs14.mb10 - = cell(:fund_insight, @fund).call(:data_source) - .mb20 - %strong= period(@fund) - - - unless @fund.open_call? - .bg-ice.rounded.shadow.fs18.lh22.p10.mb20 - .bold.caps.mb10.fs15 Unsolicited applications - Please note this fund does not accept unsolicited applications. Please read the fund guidance for more information. - - %ul.list.pl30 - = cell(:fund_insight, @fund).call(:amount) - = cell(:fund_insight, @fund).call(:costs) - = cell(:fund_insight, @fund).call(:countries) - = cell(:fund_insight, @fund).call(:duration) - = cell(:fund_insight, @fund).call(:grant_count) - = cell(:fund_insight, @fund).call(:award_months) - = cell(:fund_insight, @fund).call(:grant_examples) - - = render partial: 'layouts/sign_up_cta' diff --git a/app/views/public_funds/themed.haml b/app/views/public_funds/themed.haml deleted file mode 100644 index 9670711b..00000000 --- a/app/views/public_funds/themed.haml +++ /dev/null @@ -1,7 +0,0 @@ -= content_for :title, "#{@theme.name} Funds preview" - -%header - = cell :v2_navbar, @current_user - = cell :breadcrumb, {'Funds' => public_funds_path, @theme.name.truncate_words(4) => nil} - -= render partial: 'fund_list', locals: { name: @theme.name, funds_to_show: 1 } diff --git a/app/views/signup/user.html.haml b/app/views/signup/user.html.haml index a8b0ca0e..b4bec94c 100644 --- a/app/views/signup/user.html.haml +++ b/app/views/signup/user.html.haml @@ -68,9 +68,9 @@ %p We’ve an ever growing number of funders and funding themes ranging from the = succeed ',' do - = link_to 'Arts', public_funds_theme_path('arts') + = link_to 'Arts', theme_path('arts') to - = link_to 'Youth', public_funds_theme_path('children-and-young-people') + = link_to 'Youth', theme_path('children-and-young-people') (and everything in between) which you can easily use to narrow your search and find the right funding opportunity. .perc50.md.px40.pb20.mb40 diff --git a/config/routes.rb b/config/routes.rb index 7d3b8b6c..d535cba6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,32 +1,11 @@ Rails.application.routes.draw do - resources :articles, only: [:index, :show] - resources :password_resets, except: [:show, :index, :destroy] + resources :articles, only: %i[index show] + resources :feedback, except: %i[show index destroy] # TODO: remove + resources :password_resets, except: %i[show index destroy] + resources :proposals, except: %i[show destroy] resources :reveals, only: :create resources :requests, only: :create - get '/funds', to: 'public_funds#index', as: 'public_funds' - get '/funds/:id', to: 'public_funds#show', as: 'public_fund' - get '/funds/theme/:theme', to: 'public_funds#themed', as: 'public_funds_theme' - - resources :proposals, except: %i[show destroy] do - resources :funds, only: %i[show index] do - collection do - get '/theme/:theme', to: 'funds#themed', as: 'theme' - end - member do - patch :eligibility, to: 'eligibilities#create' - get :apply, to: 'enquiries#new' - post :apply, to: 'enquiries#create' - get :hidden, to: 'funds#hidden' - end - end - end - - get '/proposals/:id/funds?eligibility=eligible', to: 'funds#index', as: 'eligible_proposal_funds' - get '/proposals/:id/funds?eligibility=ineligible', to: 'funds#index', as: 'ineligible_proposal_funds' - - resources :feedback, except: %i[show index destroy] - # Errors match '/404', to: 'errors#not_found', via: :all match '/410', to: 'errors#gone', via: :all @@ -83,6 +62,19 @@ post '/account/:id/subscription/upgrade', to: 'charges#create' get '/account/:id/subscription/thank-you', to: 'charges#thank_you', as: 'thank_you' + # Funds + get '/funds/(:proposal_id)', to: 'funds#index', as: 'funds' + get '/fund/:id/(:proposal_id)', to: 'funds#show', as: 'fund' + get '/h/fund/:id/(:proposal_id)', to: 'funds#hidden', as: 'hidden' + get '/:theme/funds/(:proposal_id)', to: 'funds#themed', as: 'theme' + + # Eligibilities + patch '/fund/:id/:proposal_id/eligibility', to: 'eligibilities#create', as: 'eligibility' + + # Enquiries + get '/fund/:id/:proposal_id/apply', to: 'enquiries#new', as: 'apply' + post '/fund/:id/:proposal_id/apply', to: 'enquiries#create' + # Microsite get '/check/:slug', to: 'microsites#basics', as: 'microsite_basics' post '/check/:slug', to: 'microsites#check_basics' diff --git a/spec/cells/filter_cell_spec.rb b/spec/cells/filter_cell_spec.rb index cb77757d..70f82fa2 100644 --- a/spec/cells/filter_cell_spec.rb +++ b/spec/cells/filter_cell_spec.rb @@ -1,8 +1,13 @@ require 'rails_helper' describe FilterCell do - before(:each) do - @filter = cell(:filter, sort: 'eligibility', funding_duration: 12).call(:show) + let(:funding_duration) { 12 } + let(:filter) do + cell( + :filter, + { sort: 'eligibility' }, + funding_duration: funding_duration + ).call(:show) end it 'has correct options' do @@ -17,11 +22,19 @@ 'Up to 2 years', 'More than 2 years' ].each do |option| - expect(@filter).to have_text option + expect(filter).to have_text(option) + end + end + + context 'funding_duration missing' do + let(:funding_duration) { nil } + + it 'hides proposal duration option' do + expect(filter).not_to have_text('Your proposal') end end it 'selected option' do - expect(@filter).to have_select('sort', selected: 'Eligibility') + expect(filter).to have_select('sort', selected: 'Eligibility') end end diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index 34b6aa45..a178d956 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -47,8 +47,7 @@ fill_in :email, with: 'updates.user@email.com' fill_in :password, with: 'newPa55word' click_button 'Sign in' - expect(current_path) - .to eq proposal_funds_path(@db[:registered_proposal]) + expect(current_path).to eq funds_path(@db[:registered_proposal]) end scenario 'password update optional when updating user profile' diff --git a/spec/features/apply_spec.rb b/spec/features/apply_spec.rb index 9be19866..a7aa0a82 100644 --- a/spec/features/apply_spec.rb +++ b/spec/features/apply_spec.rb @@ -41,7 +41,7 @@ expect(@proposal.enquiries.last.approach_funder_count).to eq 1 expect(current_url).to eq @fund.application_link - visit apply_proposal_fund_path(@proposal, @fund) + visit apply_path(@fund, @proposal) click_link "Apply to #{@fund.title}" expect(@proposal.enquiries.last.approach_funder_count).to eq 2 end diff --git a/spec/features/browse_spec.rb b/spec/features/browse_spec.rb index c3537c8e..eb852217 100644 --- a/spec/features/browse_spec.rb +++ b/spec/features/browse_spec.rb @@ -22,7 +22,7 @@ fill_in :email, with: @db[:user].email fill_in :password, with: @db[:user].password click_button 'Sign in' - expect(current_path).to eq proposal_funds_path(@proposal) + expect(current_path).to eq funds_path(@proposal) end scenario 'When I browse the site, @@ -53,36 +53,35 @@ end it 'hidden' do - visit hidden_proposal_fund_path(@proposal, @fund) - expect(current_path).to eq(proposal_funds_path(@proposal)) + visit hidden_path(@fund, @proposal) + expect(current_path).to eq(funds_path(@proposal)) end it 'revealed' do @proposal.recipient.update(reveals: [@fund.slug]) - visit proposal_fund_path(@proposal, @fund) - expect(current_path).to eq(proposal_funds_path(@proposal)) + visit fund_path(@fund, @proposal) + expect(current_path).to eq(funds_path(@proposal)) end end scenario "Fund stub selection shown on proposal fund page" do @proposal.update_column(:eligibility, @proposal.eligibility.merge( @fund_stubs.first.slug => {'location': true}) ) - visit proposal_funds_path(@proposal) + visit funds_path(@proposal) expect(page).to have_text @fund_stubs.first.funder.name end scenario "When I visit a fund that doesn't exist, I want to be redirected to where I came from and see a message, so I avoid an error and understand what happened" do - visit proposal_fund_path(@proposal, 'missing-fund') - expect(current_path).to eq(proposal_funds_path(@proposal)) + visit fund_path('missing-fund', @proposal) + expect(current_path).to eq(funds_path(@proposal)) end scenario "When I find a funding theme I'm interested in, I want to see similar funds, so I can discover new funding opportunties" do click_link @theme.name, match: :first - expect(current_path) - .to eq(theme_proposal_funds_path(@proposal, @theme.slug)) + expect(current_path).to eq(theme_path(@theme.slug, @proposal)) expect(page).to have_css('h3', count: 6) end @@ -95,17 +94,17 @@ scenario "When I visit a funding theme which isn't listed, I want to see a message and be directed to safety, so I can continue my search" do - visit theme_proposal_funds_path(@proposal, '') + visit theme_path('missing', @proposal) # TODO: v2 flash notices #391 # expect(page.all('body script', visible: false)[0].native.text) # .to have_text 'Fund not found' - expect(current_path).to eq(proposal_funds_path(@proposal)) + expect(current_path).to eq(funds_path(@proposal)) - visit theme_proposal_funds_path(@proposal, 'missing') + visit theme_path('missing', @proposal) # TODO: v2 flash notices #391 # expect(page.all('body script', visible: false)[0].native.text) # .to have_text 'Not found' - expect(current_path).to eq proposal_funds_path(@proposal) + expect(current_path).to eq funds_path(@proposal) end def subscribe_and_visit(path) diff --git a/spec/features/eligibility_spec.rb b/spec/features/eligibility_spec.rb index c494c23b..890a060b 100644 --- a/spec/features/eligibility_spec.rb +++ b/spec/features/eligibility_spec.rb @@ -47,7 +47,7 @@ scenario "When I'm try to access application details before checking eligiblity, I want to be told why I can't access them, so I understand what to do next" do - visit apply_proposal_fund_path(@proposal, @fund) + visit apply_path(@fund, @proposal) expect(current_path).to eq(account_upgrade_path(@proposal.recipient)) end @@ -117,7 +117,7 @@ .answer_priorities(@fund).check_suitability click_link 'Reveal' click_link 'Apply ❯' - expect(current_path).to eq(apply_proposal_fund_path(@proposal, @fund)) + expect(current_path).to eq(apply_path(@fund, @proposal)) end scenario "When I run a check and I'm ineligible, @@ -152,7 +152,7 @@ helper.answer_recipient_restrictions(@fund) .answer_proposal_restrictions(@fund, eligible: false) .check_eligibility - visit proposal_fund_path(@proposal, Fund.last) + visit fund_path(Fund.last, @proposal) helper.check_eligibility # 3 questions previously answered should be checked @@ -167,7 +167,7 @@ .answer_proposal_restrictions(@fund, eligible: false) .check_eligibility click_link 'Reveal' - visit apply_proposal_fund_path(@proposal, @fund) + visit apply_path(@fund, @proposal) expect(current_path).to eq(account_upgrade_path(@proposal.recipient)) end end diff --git a/spec/features/match_spec.rb b/spec/features/match_spec.rb index 79b8652f..748447dc 100644 --- a/spec/features/match_spec.rb +++ b/spec/features/match_spec.rb @@ -213,6 +213,7 @@ def expect_company_lookup(count: 1) scenario "When I complete my first funding proposal, I want to see a shortlist of the most relevant funds, so I feel I've found suitable funding opportunities" do + Fund.last.update(max_org_income_limited: false) helper.submit_user_form! expect(current_path).to eq new_signup_recipient_path @@ -232,11 +233,10 @@ def expect_company_lookup(count: 1) expect(current_path).to eq new_signup_proposal_path helper.submit_proposal_form - expect(current_path).to eq proposal_funds_path(Proposal.last) + expect(current_path).to eq funds_path(Proposal.last) expect(page).to have_text 'Hidden fund', count: 3 click_link 'Hidden fund', match: :first - expect(current_path) - .to eq hidden_proposal_fund_path(Proposal.last, Fund.first) + expect(current_path).to eq hidden_path(Fund.last, Proposal.last) end end diff --git a/spec/features/proposal_spec.rb b/spec/features/proposal_spec.rb index 6ee689f4..42001802 100644 --- a/spec/features/proposal_spec.rb +++ b/spec/features/proposal_spec.rb @@ -21,15 +21,13 @@ I want to be told why I am redirected, so I know what to do next' do [ - proposal_funds_path('missing'), - eligible_proposal_funds_path('missing'), - ineligible_proposal_funds_path('missing'), + funds_path('missing'), account_subscription_path(@recipient), account_upgrade_path(@recipient), edit_proposal_path('missing'), - apply_proposal_fund_path('missing', @fund), - proposal_fund_path('missing', @fund), - theme_proposal_funds_path('missing', @theme.slug), + apply_path(@fund, 'missing'), + fund_path(@fund, 'missing'), + theme_path(@theme.slug, 'missing'), new_feedback_path, edit_feedback_path(1) ].each do |path| @@ -43,7 +41,7 @@ so I can see my results' do expect(current_path).to eq new_signup_proposal_path match.submit_proposal_form - expect(current_path).to eq proposal_funds_path(Proposal.last) + expect(current_path).to eq funds_path(Proposal.last) end context 'registered' do @@ -55,9 +53,7 @@ scenario 'When I create my first proposal, I want to see options to change it or create a new one' do [ - proposal_funds_path(@proposal), - eligible_proposal_funds_path(@proposal), - ineligible_proposal_funds_path(@proposal) + funds_path(@proposal) ].each do |path| visit path expect(page).to have_link(nil, href: edit_proposal_path(@proposal)) @@ -81,7 +77,7 @@ eligibility_helper.complete_proposal click_button 'Update and review recommendations' - expect(current_path).to eq proposal_funds_path(@proposal) + expect(current_path).to eq funds_path(@proposal) # expect upgrade prompt click_link 'New' @@ -95,7 +91,7 @@ # can create multiple proposals click_link 'Continue' - expect(current_path).to eq proposal_funds_path(@proposal) + expect(current_path).to eq funds_path(@proposal) StripeMock.stop end @@ -113,8 +109,8 @@ unauthorised_proposal = @app.instances[:complete_proposal] unauthorised_proposal.update(recipient: create(:recipient)) - visit proposal_funds_path(unauthorised_proposal) - expect(current_path).to eq proposal_funds_path(@proposal) + visit funds_path(unauthorised_proposal) + expect(current_path).to eq funds_path(@proposal) end scenario 'When I try to create a new proposal from the proposals index, @@ -133,7 +129,7 @@ scenario 'When I have funding proposals, I want to be able to edit them, so I make any neccessary changes' do - visit proposal_funds_path(@proposal) + visit funds_path(@proposal) click_link 'Dashboard' expect(current_path).to eq proposals_path @@ -156,7 +152,7 @@ eligibility.complete_proposal click_button 'Update and review recommendations' - expect(current_path).to eq proposal_funds_path(@proposal) + expect(current_path).to eq funds_path(@proposal) end end @@ -203,7 +199,7 @@ @eligibility_helper.complete_proposal click_button 'Save and recommend funders' - expect(current_path).to eq proposal_funds_path(Proposal.last) + expect(current_path).to eq funds_path(Proposal.last) click_link 'Change' expect(page).to have_css '.proposal', count: 2 @@ -215,13 +211,13 @@ proposal1 = @app.instances[:complete_proposal] visit proposals_path click_link 'Funds', match: :first - expect(current_path).to eq proposal_funds_path(proposal1) + expect(current_path).to eq funds_path(proposal1) @app.create_registered_proposal proposal2 = @app.instances[:registered_proposal] visit proposals_path click_link 'Funds', match: :first - expect(current_path).to eq proposal_funds_path(proposal2) + expect(current_path).to eq funds_path(proposal2) end end @@ -230,7 +226,7 @@ so I can update my proposal' do @app.create_initial_proposal proposal = Proposal.last - visit proposal_funds_path(proposal) + visit funds_path(proposal) expect(current_path).to eq new_signup_proposal_path expect(page).to have_text 'Your details are out of date' end @@ -248,7 +244,7 @@ @db[:user].organisation = recipient @db[:user].save @app.sign_in - visit proposal_funds_path(proposal) + visit funds_path(proposal) expect(current_path).to eq edit_signup_recipient_path(recipient) expect(page).to have_text 'Your details are out of date' fill_in :recipient_street_address, with: 'London Road' diff --git a/spec/features/public_funds_spec.rb b/spec/features/public_funds_spec.rb deleted file mode 100644 index 2cfc9cb6..00000000 --- a/spec/features/public_funds_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -require 'rails_helper' - -feature 'PublicFunds' do - before(:each) do - @app.seed_test_db.setup_funds(num: 7, open_data: true) - @public_fund = Fund.last - @private_fund = Fund.first - end - - context 'public_funds#index' do - before(:each) do - visit public_funds_path - end - - scenario 'logged_in? redirects to funds#index' do - @app.create_recipient.with_user.create_registered_proposal.sign_in - proposal = @app.instances[:registered_proposal] - - visit public_funds_path - expect(current_path).to eq proposal_funds_path(proposal) - end - - scenario 'navigate' do - visit root_path - click_link 'Funds' - expect(current_path).to eq public_funds_path - end - - scenario 'public fund visible' do - expect(page).to have_css('a.fs22', count: 3) - end - - scenario 'private fund redacted' do - expect(page).to have_css('.fs22.redacted', count: 3) - end - - scenario 'can click visible fund' do - click_link @public_fund.name - expect(current_path).to eq public_fund_path(@public_fund) - end - - scenario 'page 2 all redacted' do - click_link '2' - expect(page).to have_css('.fs22.redacted', count: 1) - end - end - - context 'public_funds#show' do - scenario 'logged_in? redirects to funds#show' do - @app.create_recipient.with_user.create_registered_proposal.sign_in - proposal = @app.instances[:registered_proposal] - - visit public_fund_path(@public_fund) - expect(current_path).to eq proposal_funds_path(proposal) - end - - scenario 'visit public fund' do - visit public_fund_path(@public_fund) - expect(current_path).to eq public_fund_path(@public_fund) - end - - scenario 'visit private fund' do - visit public_fund_path(@private_fund) - expect(current_path).to eq public_funds_path - end - - scenario 'missing fund' do - visit public_fund_path('missing') - expect(current_path).to eq public_funds_path - end - end -end diff --git a/spec/features/reveal_spec.rb b/spec/features/reveal_spec.rb index 8de5658a..7b39174a 100644 --- a/spec/features/reveal_spec.rb +++ b/spec/features/reveal_spec.rb @@ -18,7 +18,7 @@ context 'v2 subscription' do before(:each) do Subscription.last.update(version: 2) - visit proposal_fund_path(@proposal, @fund) + visit fund_path(@fund, @proposal) end scenario 'reveal button hidden once revealed' do @@ -29,14 +29,14 @@ scenario 'Featured fund does not need to be revealed' do @fund.update(featured: true) - visit proposal_fund_path(@proposal, @fund) + visit fund_path(@fund, @proposal) expect(page).not_to have_link('Reveal') end context 'limit reached' do before(:each) do @recipient.update(reveals: [1, 2, 3]) - visit proposal_fund_path(@proposal, @fund) + visit fund_path(@fund, @proposal) end scenario 'cant reveal fund after reaching limit' do @@ -45,9 +45,9 @@ end scenario 'can browse redacted fund after reaching limit' do - visit proposal_funds_path(@proposal) + visit funds_path(@proposal) click_link('Hidden fund', match: :first) - expect(current_path).to eq(hidden_proposal_fund_path(@proposal, @fund)) + expect(current_path).to eq(hidden_path(@fund, @proposal)) end scenario 'can check eligibility after reaching limit' do @@ -61,19 +61,19 @@ scenario 'can apply once revealed' do create(:eligible, fund: @fund, proposal: @proposal) - visit apply_proposal_fund_path(@proposal, @fund) + visit apply_path(@fund, @proposal) expect(current_path).to eq(account_upgrade_path(@recipient)) @recipient.update(reveals: [@fund.slug]) - visit apply_proposal_fund_path(@proposal, @fund) - expect(current_path).to eq(apply_proposal_fund_path(@proposal, @fund)) + visit apply_path(@fund, @proposal) + expect(current_path).to eq(apply_path(@fund, @proposal)) end scenario 'can apply once subscribed' do create(:eligible, fund: @fund, proposal: @proposal) @recipient.subscribe! - visit apply_proposal_fund_path(@proposal, @fund) - expect(current_path).to eq(apply_proposal_fund_path(@proposal, @fund)) + visit apply_path(@fund, @proposal) + expect(current_path).to eq(apply_path(@fund, @proposal)) end end end diff --git a/spec/features/sessions_spec.rb b/spec/features/sessions_spec.rb index 1d468920..c0e46cd6 100644 --- a/spec/features/sessions_spec.rb +++ b/spec/features/sessions_spec.rb @@ -37,7 +37,7 @@ def expect_path(array) it 'enquiries' do expect_path([ - apply_proposal_fund_path(@proposal, @fund) + apply_path(@fund, @proposal) ]) end @@ -48,16 +48,6 @@ def expect_path(array) ]) end - it 'funds' do - expect_path([ - proposal_funds_path(@proposal), - eligible_proposal_funds_path(@proposal), - ineligible_proposal_funds_path(@proposal), - theme_proposal_funds_path(@proposal, @theme.slug), - proposal_fund_path(@proposal, @fund) - ]) - end - it 'proposals' do expect_path([ proposals_path, diff --git a/spec/features/subscriptions_spec.rb b/spec/features/subscriptions_spec.rb index d16a1a88..8bb23833 100644 --- a/spec/features/subscriptions_spec.rb +++ b/spec/features/subscriptions_spec.rb @@ -175,7 +175,7 @@ scenario 'remaining free checks hidden' do @app.setup_funds @db[:complete_proposal].save! - visit proposal_fund_path(@db[:complete_proposal], Fund.first) + visit fund_path(Fund.first, @db[:complete_proposal]) expect(page).not_to have_button 'Check eligibility (3 left)' end end diff --git a/spec/policies/enquiry_policy_spec.rb b/spec/policies/enquiry_policy_spec.rb index 925f7229..919e6e86 100644 --- a/spec/policies/enquiry_policy_spec.rb +++ b/spec/policies/enquiry_policy_spec.rb @@ -4,110 +4,44 @@ describe EnquiryPolicy do subject { described_class } - let(:version) { 1 } - let(:subscribed) { false } - let(:eligibility) { {} } - let(:suitability) { {} } - - let(:fund) { Fund.new(slug: 'fund', state: 'active') } - let(:proposal) do - Proposal.new(eligibility: eligibility, suitability: suitability) - end let(:reveals) { [] } let(:user) do - instance_double( - User, - subscription_active?: subscribed, - subscription_version: version, - reveals: reveals - ) + instance_double(User, subscription_active?: subscribed, reveals: reveals) end - context 'v1' do # TODO: deprecated - permissions :new?, :create? do - context 'eligible' do - let(:eligibility) do - { fund.slug => { 'quiz' => { 'eligible' => true } } } - end - - it 'fund not recommended denies access' do - is_expected.not_to permit(user, EnquiryContext.new(fund, proposal)) - end - - context 'fund recommended' do - let(:suitability) { { fund.slug => { 'total' => 1 } } } + let(:eligibility) { ELIGIBLE } + let(:assessment) { create(:eligible, eligibility_quiz: eligibility) } + let(:context) { EnquiryContext.new(assessment.fund, assessment.proposal) } - it 'grants access' do - is_expected.to permit(user, EnquiryContext.new(fund, proposal)) - end - end - end - - it 'ineligible denies access' do - is_expected.not_to permit(user, EnquiryContext.new(fund, proposal)) - end - - context 'user subscribed' do - let(:subscribed) { true } - - it 'grants access' do - is_expected.to permit(user, EnquiryContext.new(fund, proposal)) - end - end + permissions :new?, :create? do + it 'denies access if no fund supplied' do + is_expected.not_to permit(user, context) end - end - - context 'v2' do - let(:version) { 2 } - let(:assessment) { create(:assessment, eligibility_quiz: eligibility) } - let(:fund) { assessment.fund } - let(:proposal) { assessment.proposal } - permissions :new?, :create? do - it 'denies access if no fund supplied' do - is_expected.not_to permit(user, EnquiryContext.new(fund, proposal)) - end - - context 'incomplete' do - let(:eligibility) { nil } - - it 'denies access' do - is_expected.not_to permit(user, EnquiryContext.new(fund, proposal)) - end - end - - context 'ineligible' do - let(:eligibility) { 0 } - - it 'denies access' do - is_expected.not_to permit(user, EnquiryContext.new(fund, proposal)) - end - end - - context 'eligible and subscribed' do - let(:eligibility) { 1 } - let(:subscribed) { true } + context 'incomplete' do + let(:eligibility) { INCOMPLETE } + it { is_expected.not_to permit(user, context) } + end - it 'grants access' do - is_expected.to permit(user, EnquiryContext.new(fund, proposal)) - end - end + context 'ineligible' do + let(:eligibility) { INELIGIBLE } + it { is_expected.not_to permit(user, context) } + end - context 'eligible and revealed' do - let(:eligibility) { 1 } - let(:reveals) { [fund.slug] } + context 'eligible and subscribed' do + let(:subscribed) { true } + it { is_expected.to permit(user, context) } + end - it 'grants access' do - is_expected.to permit(user, EnquiryContext.new(fund, proposal)) - end - end + context 'eligible and revealed' do + let(:reveals) { [assessment.fund.slug] } + it { is_expected.to permit(user, context) } + end - context 'fund not revealed' do - it 'denies access' do - is_expected.not_to permit(user, EnquiryContext.new(fund, proposal)) - end - end + context 'fund not revealed' do + it { is_expected.not_to permit(user, context) } end end + end diff --git a/spec/policies/fund_policy_spec.rb b/spec/policies/fund_policy_spec.rb index 17e0dd6b..bba11a23 100644 --- a/spec/policies/fund_policy_spec.rb +++ b/spec/policies/fund_policy_spec.rb @@ -4,96 +4,37 @@ describe FundPolicy do subject { described_class } - let(:version) { 1 } - let(:subscribed) { false } - let(:suitability) { {} } - - let(:fund) { Fund.new(slug: 'fund', state: 'active') } - let(:proposal) { Proposal.new(suitability: suitability) } + let(:fund) { build(:fund) } let(:reveals) { [] } let(:user) do - instance_double( - User, - subscription_active?: subscribed, - subscription_version: version, - reveals: reveals - ) + instance_double(User, subscription_active?: subscribed, reveals: reveals) end + let(:context) { FundContext.new(fund, build(:proposal)) } - context 'v1' do - permissions :show? do - it 'denies access if no fund supplied' do - is_expected.not_to permit(user, FundContext.new(nil, proposal)) - end - - it 'denies access if no proposal supplied' do - is_expected.not_to permit(user, FundContext.new(fund, nil)) - end - - context 'user subscribed' do - let(:subscribed) { true } - - it 'grants access' do - is_expected.to permit(user, FundContext.new(fund, proposal)) - end - end - - context 'fund recommended' do - let(:suitability) { { fund.slug => { 'total' => 1 } } } - - it 'grants access' do - is_expected.to permit(user, FundContext.new(fund, proposal)) - end - end - - context 'fund not recommended' do - it 'denies access' do - is_expected.not_to permit(user, FundContext.new(fund, proposal)) - end - end + permissions :show? do + it 'denies access if no fund supplied' do + is_expected.not_to permit(user, context) end - end - context 'v2' do - let(:version) { 2 } - let(:context) { FundContext.new(fund, proposal) } # TODO: refactor - - permissions :show? do - it 'denies access if no fund supplied' do - is_expected.not_to permit(user, context) - end - - context 'user subscribed' do - let(:subscribed) { true } - - it 'grants access' do - is_expected.to permit(user, context) - end - end - - context 'fund revealed' do - let(:reveals) { [fund.slug] } - - it 'grants access' do - is_expected.to permit(user, context) - end - end + context 'user subscribed' do + let(:subscribed) { true } + it { is_expected.to permit(user, context) } + end - context 'fund revealed and subscribed' do - let(:subscribed) { true } - let(:reveals) { [fund.slug] } + context 'fund revealed' do + let(:reveals) { [fund.slug] } + it { is_expected.to permit(user, context) } + end - it 'grants access' do - is_expected.to permit(user, context) - end - end + context 'fund revealed and subscribed' do + let(:subscribed) { true } + let(:reveals) { [fund.slug] } + it { is_expected.to permit(user, context) } + end - context 'fund not revealed' do - it 'denies access' do - is_expected.not_to permit(user, context) - end - end + context 'fund not revealed' do + it { is_expected.not_to permit(user, context) } end end end