From af66e69ca5946939f958e3e90b1c5b179a85f359 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sat, 22 Jan 2022 07:40:10 +0100 Subject: [PATCH] Add tests for `FeedbackHelper` --- spec/helpers/feedback_helper_spec.rb | 38 ++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 spec/helpers/feedback_helper_spec.rb diff --git a/spec/helpers/feedback_helper_spec.rb b/spec/helpers/feedback_helper_spec.rb new file mode 100644 index 00000000..93835aa8 --- /dev/null +++ b/spec/helpers/feedback_helper_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +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' + } + }) + 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') } + + before(:each) { + sign_in(user) + } + + it "should return a proper token" do + expect(helper.canny_token).to eq("eyJhbGciOiJIUzI1NiJ9.eyJhdmF0YXJVUkwiOiIvaW1hZ2VzL2xhcmdlL25vX2F2YXRhci5wbmciLCJuYW1lIjoiY2FubmVkX2xhdWdodGVyIiwiaWQiOjEwLCJlbWFpbCI6ImNhbkBkby5jb20ifQ.aRZn8kAezMJucYQV4RXiMPvhSRVR3wKp1ZQtcsIWaaE") + end + end + + context "user not signed in" do + it "should return nothing" do + expect(helper.canny_token).to eq(nil) + end + end + end +end \ No newline at end of file