2018-12-27 14:22:04 +01:00
|
|
|
require 'rails_helper'
|
2016-06-08 16:45:18 +02:00
|
|
|
|
2018-12-27 14:22:04 +01:00
|
|
|
RSpec.describe AdminFormulaireHelper, type: :helper do
|
2016-06-08 16:45:18 +02:00
|
|
|
let(:procedure) { create(:procedure) }
|
2018-12-27 14:22:04 +01:00
|
|
|
let(:kind) { 'piece_justificative' }
|
2016-06-08 16:45:18 +02:00
|
|
|
let(:url) { 'http://localhost' }
|
|
|
|
let!(:type_de_piece_justificative_0) { create(:type_de_piece_justificative, procedure: procedure, order_place: 0) }
|
|
|
|
let!(:type_de_piece_justificative_1) { create(:type_de_piece_justificative, procedure: procedure, order_place: 1) }
|
|
|
|
let!(:type_de_piece_justificative_2) { create(:type_de_piece_justificative, procedure: procedure, order_place: 2) }
|
|
|
|
|
|
|
|
describe '#button_up' do
|
|
|
|
describe 'with first piece justificative' do
|
|
|
|
let(:index) { 0 }
|
|
|
|
|
|
|
|
it 'returns a button up' do
|
2018-12-27 14:22:04 +01:00
|
|
|
expect(button_up(procedure, kind, index, url)).to be(nil)
|
2016-06-08 16:45:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with second out of three piece justificative' do
|
|
|
|
let(:index) { 1 }
|
|
|
|
|
|
|
|
it 'returns a button up' do
|
2018-12-27 14:22:04 +01:00
|
|
|
expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
|
2016-06-08 16:45:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with last piece justificative' do
|
|
|
|
let(:index) { 2 }
|
|
|
|
|
|
|
|
it 'returns a button up' do
|
2018-12-27 14:22:04 +01:00
|
|
|
expect(button_up(procedure, kind, index, url)).to match(/fa-chevron-up/)
|
2016-06-08 16:45:18 +02:00
|
|
|
end
|
2018-12-27 14:22:04 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#button_down' do
|
|
|
|
describe 'with first piece justificative' do
|
|
|
|
let(:index) { 0 }
|
|
|
|
|
2016-06-08 16:45:18 +02:00
|
|
|
it 'returns a button down' do
|
2018-12-27 14:22:04 +01:00
|
|
|
expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with second out of three piece justificative' do
|
|
|
|
let(:index) { 1 }
|
|
|
|
|
|
|
|
it 'returns a button down' do
|
|
|
|
expect(button_down(procedure, kind, index, url)).to match(/fa-chevron-down/)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'with last piece justificative' do
|
|
|
|
let(:index) { 2 }
|
|
|
|
|
|
|
|
it 'returns nil' do
|
|
|
|
expect(button_down(procedure, kind, index, url)).to be(nil)
|
2016-06-08 16:45:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|