mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:39:52 +01:00
Add tests for FeedbackController
This commit is contained in:
parent
7374aba6d3
commit
067dfc3a50
1 changed files with 100 additions and 0 deletions
100
spec/controllers/feedback_controller_spec.rb
Normal file
100
spec/controllers/feedback_controller_spec.rb
Normal file
|
@ -0,0 +1,100 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
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'
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
describe "#consent" do
|
||||
context "user signed in without consent" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
||||
before(:each) { sign_in(user) }
|
||||
|
||||
it "renders the consent template" 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
|
||||
let(:user) { FactoryBot.create(:user, roles: [:canny_consent]) }
|
||||
|
||||
before(:each) { sign_in(user) }
|
||||
|
||||
it "redirects away from the consent page" do
|
||||
get :consent
|
||||
expect(response).to redirect_to(feedback_bugs_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#features" do
|
||||
subject { get :features }
|
||||
|
||||
context "user signed in with consent" do
|
||||
let(:user) { FactoryBot.create(:user, roles: [:canny_consent]) }
|
||||
|
||||
before(:each) { sign_in(user) }
|
||||
|
||||
it "renders the features template" do
|
||||
subject
|
||||
expect(response).to render_template(:features)
|
||||
end
|
||||
end
|
||||
|
||||
context "user signed in without consent" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
||||
before(:each) { sign_in(user) }
|
||||
|
||||
it "redirects to the consent page" do
|
||||
subject
|
||||
expect(response).to redirect_to(feedback_consent_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#bugs" do
|
||||
subject { get :bugs }
|
||||
|
||||
context "user signed in with consent" do
|
||||
let(:user) { FactoryBot.create(:user, roles: [:canny_consent]) }
|
||||
|
||||
before(:each) { sign_in(user) }
|
||||
|
||||
it "renders the bugs template" do
|
||||
subject
|
||||
expect(response).to render_template(:bugs)
|
||||
end
|
||||
end
|
||||
|
||||
context "user signed in without consent" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
|
||||
before(:each) { sign_in(user) }
|
||||
|
||||
it "redirects to the consent page" do
|
||||
subject
|
||||
expect(response).to redirect_to(feedback_consent_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue