Move consent POST-logic to separate action
This commit is contained in:
parent
1933aaac7f
commit
d56dfc02f9
|
@ -7,7 +7,9 @@ class FeedbackController < ApplicationController
|
|||
|
||||
def consent
|
||||
redirect_to feedback_bugs_path if current_user.has_role? :canny_consent
|
||||
end
|
||||
|
||||
def update
|
||||
return unless params[:consent] == "true"
|
||||
|
||||
current_user.add_role :canny_consent
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
%a.text-muted{ href: "https://canny.io/privacy" } Canny's Privacy Policy
|
||||
|
||||
%p
|
||||
= button_to "Consent and proceed", feedback_consent_path, class: "btn btn-primary", method: :post, params: { consent: true }
|
||||
= button_to "Consent and proceed", feedback_consent_update_path, class: "btn btn-primary", method: :post, params: { consent: true }
|
||||
|
||||
%p
|
||||
Alternatively, you can send us bug reports and feature requests directly on GitHub.
|
||||
|
|
|
@ -144,7 +144,8 @@ Rails.application.routes.draw do
|
|||
match '/:username/lists(/p/:page)', to: 'user#lists', via: 'get', as: :show_user_lists, defaults: {page: 1}
|
||||
match '/:username/questions(/p/:page)', to: 'user#questions', via: 'get', as: :show_user_questions, defaults: {page: 1}
|
||||
|
||||
match '/feedback/consent', to: 'feedback#consent', via: ['get', 'post'], as: 'feedback_consent'
|
||||
match '/feedback/consent', to: 'feedback#consent', via: 'get', as: 'feedback_consent'
|
||||
match '/feedback/consent/update', to: 'feedback#update', via: 'post', as: 'feedback_consent_update'
|
||||
match '/feedback/bugs(/*any)', to: 'feedback#bugs', via: 'get', as: 'feedback_bugs'
|
||||
match '/feedback/feature_requests(/*any)', to: 'feedback#features', via: 'get', as: 'feedback_features'
|
||||
|
||||
|
|
|
@ -26,12 +26,6 @@ describe FeedbackController, type: :controller do
|
|||
get :consent
|
||||
expect(response).to render_template(:consent)
|
||||
end
|
||||
|
||||
it "sets the consent role" do
|
||||
post :consent, params: { consent: "true" }
|
||||
expect(user.has_role?(:canny_consent)).to eq(true)
|
||||
expect(response).to redirect_to(feedback_bugs_path)
|
||||
end
|
||||
end
|
||||
|
||||
context "user signed in with consent" do
|
||||
|
@ -46,6 +40,18 @@ describe FeedbackController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
||||
before(:each) { sign_in(user) }
|
||||
|
||||
it "sets the consent role" do
|
||||
post :update, params: { consent: "true" }
|
||||
expect(user.has_role?(:canny_consent)).to eq(true)
|
||||
expect(response).to redirect_to(feedback_bugs_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#features" do
|
||||
subject { get :features }
|
||||
|
||||
|
|
Loading…
Reference in New Issue