add arrow in view for order place managment

This commit is contained in:
Tanguy PATTE 2015-11-17 18:22:15 +01:00
parent cf81623937
commit 1ab89b63aa
4 changed files with 50 additions and 21 deletions

View file

@ -2,16 +2,39 @@ require 'spec_helper'
describe 'admin/types_de_champ/show.html.haml', type: :view do
let(:procedure) { create(:procedure) }
let(:first_libelle) { 'salut la compagnie' }
let(:last_libelle) { 'je suis bien sur la page' }
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1, libelle: last_libelle) }
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0, libelle: first_libelle) }
before do
procedure.reload
assign(:procedure, procedure)
render
describe 'fields sorted' do
let(:first_libelle) { 'salut la compagnie' }
let(:last_libelle) { 'je suis bien sur la page' }
let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1, libelle: last_libelle) }
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0, libelle: first_libelle) }
before do
procedure.reload
assign(:procedure, procedure)
render
end
it 'sorts by order place' do
expect(rendered).to match(/#{first_libelle}.*#{last_libelle}/m)
end
end
it 'sorts by order place' do
expect(rendered).to match(/#{first_libelle}.*#{last_libelle}/m)
describe 'arrow button' do
subject do
procedure.reload
assign(:procedure, procedure)
render
rendered
end
context 'when there is only one field' do
it { expect(subject).not_to have_css('.fa-chevron-down') }
it { expect(subject).not_to have_css('.fa-chevron-up') }
end
context 'when two fields' do
let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) }
it { expect(subject).to have_css('#btn_down_0.fa-chevron-down') }
it { expect(subject).not_to have_css('#btn_up_0') }
it { expect(subject).to have_css('#btn_up_1.fa-chevron-up') }
it { expect(subject).not_to have_css('#btn_down_1') }
end
end
end