Add tests for `FeedbackHelper`

This commit is contained in:
Andreas Nedbal 2022-01-22 07:40:10 +01:00 committed by Andreas Nedbal
parent 067dfc3a50
commit af66e69ca5
1 changed files with 38 additions and 0 deletions

View File

@ -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