Merge pull request #730 from sgmap/fix-719
[Fix #719] Unformat date and yes/no values in the form
This commit is contained in:
commit
42663ca110
4 changed files with 43 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
%input.form-control{ name: "champs['#{champ.id}']",
|
||||
placeholder: "JJ/MM/AAAA",
|
||||
id: "champs_#{champ.id}",
|
||||
value: champ.value,
|
||||
value: champ.value ? champ.object.value : champ.value,
|
||||
type: "date" }
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
%div
|
||||
%label.radio-inline
|
||||
= radio_button_tag "champs['#{champ.id}']", "true", champ.value == 'true'
|
||||
= radio_button_tag "champs['#{champ.id}']", "true", champ.object.value == 'true'
|
||||
Oui
|
||||
|
||||
%label.radio-inline
|
||||
= radio_button_tag "champs['#{champ.id}']", "false", champ.value == 'false'
|
||||
= radio_button_tag "champs['#{champ.id}']", "false", champ.object.value == 'false'
|
||||
Non
|
||||
|
|
15
spec/views/users/description/champs/_date.html.haml_spec.rb
Normal file
15
spec/views/users/description/champs/_date.html.haml_spec.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/date.html.haml', type: :view do
|
||||
let(:type_champ) { create(:type_de_champ_public, type_champ: :date) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/date.html.haml', champ: champ
|
||||
end
|
||||
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "2017-09-19").decorate }
|
||||
|
||||
it 'should render an input for the dossier link' do
|
||||
expect(rendered).to have_css("input[value='2017-09-19']")
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'users/description/champs/yes_no.html.haml', type: :view do
|
||||
let(:type_champ) { create(:type_de_champ_public, type_champ: :yes_no) }
|
||||
|
||||
before do
|
||||
render 'users/description/champs/yes_no.html.haml', champ: champ
|
||||
end
|
||||
|
||||
context "when the value is Oui" do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "true").decorate }
|
||||
|
||||
it 'should select the Oui radio button' do
|
||||
expect(rendered).to have_selector("input[value='true'][checked]")
|
||||
end
|
||||
end
|
||||
|
||||
context "when the value is Non" do
|
||||
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "false").decorate }
|
||||
|
||||
it 'should select the Non radio button' do
|
||||
expect(rendered).to have_selector("input[value='false'][checked]")
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue