Fix Ruby codestyle
This commit is contained in:
parent
af66e69ca5
commit
3711c676da
|
@ -1,29 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class FeedbackController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
before_action :feature_enabled?
|
||||
before_action :canny_consent_given?, only: %w(features bugs)
|
||||
before_action :canny_consent_given?, only: %w[features bugs]
|
||||
|
||||
def consent
|
||||
redirect_to feedback_bugs_path if current_user.has_role? :canny_consent
|
||||
|
||||
if params[:consent] === 'true' then
|
||||
return unless params[:consent] == "true"
|
||||
|
||||
current_user.add_role :canny_consent
|
||||
redirect_to feedback_bugs_path
|
||||
end
|
||||
end
|
||||
|
||||
def features
|
||||
def features; end
|
||||
|
||||
end
|
||||
|
||||
def bugs
|
||||
|
||||
end
|
||||
def bugs; end
|
||||
|
||||
private
|
||||
|
||||
def feature_enabled?
|
||||
redirect_to root_path if APP_CONFIG['canny'].nil?
|
||||
redirect_to root_path if APP_CONFIG["canny"].nil?
|
||||
end
|
||||
|
||||
def canny_consent_given?
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module FeedbackHelper
|
||||
def canny_token
|
||||
return if current_user.nil?
|
||||
|
||||
userData = {
|
||||
user_data = {
|
||||
avatarURL: current_user.profile_picture.url(:large),
|
||||
name: current_user.screen_name,
|
||||
id: current_user.id,
|
||||
email: current_user.email
|
||||
}
|
||||
|
||||
JWT.encode(userData, APP_CONFIG.dig("canny", "sso"))
|
||||
JWT.encode(user_data, APP_CONFIG.dig("canny", "sso"))
|
||||
end
|
||||
end
|
|
@ -5,13 +5,13 @@ require "rails_helper"
|
|||
describe FeedbackController, type: :controller do
|
||||
before do
|
||||
stub_const("APP_CONFIG", {
|
||||
'hostname' => 'example.com',
|
||||
'https' => true,
|
||||
'items_per_page' => 5,
|
||||
'canny' => {
|
||||
'sso': 'sso',
|
||||
'feature_board': 'feature',
|
||||
'bug_board': 'bug'
|
||||
"hostname" => "example.com",
|
||||
"https" => true,
|
||||
"items_per_page" => 5,
|
||||
"canny" => {
|
||||
sso: "sso",
|
||||
feature_board: "feature",
|
||||
bug_board: "bug"
|
||||
}
|
||||
})
|
||||
end
|
||||
|
@ -28,7 +28,7 @@ describe FeedbackController, type: :controller do
|
|||
end
|
||||
|
||||
it "sets the consent role" do
|
||||
post :consent, params: { consent: 'true' }
|
||||
post :consent, params: { consent: "true" }
|
||||
expect(user.has_role?(:canny_consent)).to eq(true)
|
||||
expect(response).to redirect_to(feedback_bugs_path)
|
||||
end
|
||||
|
|
|
@ -5,24 +5,24 @@ require "rails_helper"
|
|||
describe FeedbackHelper, type: :helper do
|
||||
before do
|
||||
stub_const("APP_CONFIG", {
|
||||
'hostname' => 'example.com',
|
||||
'https' => true,
|
||||
'items_per_page' => 5,
|
||||
'canny' => {
|
||||
'sso': 'sso',
|
||||
'feature_board': 'feature',
|
||||
'bug_board': 'bug'
|
||||
"hostname" => "example.com",
|
||||
"https" => true,
|
||||
"items_per_page" => 5,
|
||||
"canny" => {
|
||||
sso: "sso",
|
||||
feature_board: "feature",
|
||||
bug_board: "bug"
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
describe "#canny_token" do
|
||||
context "user signed in" do
|
||||
let(:user) { FactoryBot.create(:user, id: 10, screen_name: "canned_laughter", email: 'can@do.com') }
|
||||
let(:user) { FactoryBot.create(:user, id: 10, screen_name: "canned_laughter", email: "can@do.com") }
|
||||
|
||||
before(:each) {
|
||||
before(:each) do
|
||||
sign_in(user)
|
||||
}
|
||||
end
|
||||
|
||||
it "should return a proper token" do
|
||||
expect(helper.canny_token).to eq("eyJhbGciOiJIUzI1NiJ9.eyJhdmF0YXJVUkwiOiIvaW1hZ2VzL2xhcmdlL25vX2F2YXRhci5wbmciLCJuYW1lIjoiY2FubmVkX2xhdWdodGVyIiwiaWQiOjEwLCJlbWFpbCI6ImNhbkBkby5jb20ifQ.aRZn8kAezMJucYQV4RXiMPvhSRVR3wKp1ZQtcsIWaaE")
|
||||
|
|
Loading…
Reference in New Issue