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