demarches-normaliennes/spec/controllers/support_controller_spec.rb

65 lines
1.4 KiB
Ruby
Raw Normal View History

2018-08-29 11:44:12 +02:00
require 'spec_helper'
describe SupportController, type: :controller do
render_views
context 'signed in' do
before do
sign_in user
end
let(:user) { create(:user) }
describe "with dossier" do
let(:user) { dossier.user }
let(:dossier) { create(:dossier) }
it 'should fill dossier_id' do
get :index, params: { dossier_id: dossier.id }
expect(response.status).to eq(200)
expect(response.body).to include("#{dossier.id}")
end
it 'should not have email field' do
get :index
expect(response.status).to eq(200)
expect(response.body).not_to have_content("Email *")
end
end
describe "with dossier" do
let(:tag) { 'yolo' }
it 'should fill tags' do
get :index, params: { tags: [tag] }
expect(response.status).to eq(200)
expect(response.body).to include(tag)
end
end
end
context 'signed out' do
describe "with dossier" do
it 'should have email field' do
get :index
expect(response.status).to eq(200)
expect(response.body).to have_content("Email *")
end
end
describe "with dossier" do
let(:tag) { 'yolo' }
it 'should fill tags' do
get :index, params: { tags: [tag] }
expect(response.status).to eq(200)
expect(response.body).to include(tag)
end
end
end
end