Merge pull request #981 from sgmap/fix_980

[Fix# 980] Engagement checkbox should be checked sometimes
This commit is contained in:
gregoirenovel 2017-11-23 09:41:09 +01:00 committed by GitHub
commit 0ae4536369
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -1,2 +1,2 @@
%input{ type: 'hidden', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", value: '' } %input{ type: 'hidden', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", value: '' }
%input{ type: 'checkbox', style: 'margin-left: 15px;', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.value == 'on') } %input{ type: 'checkbox', style: 'margin-left: 15px;', name: "champs['#{champ.id}']", id: "champs_#{champ.id}", checked: ('checked' if champ.object.value == 'on') }

View file

@ -0,0 +1,20 @@
require 'spec_helper'
describe 'users/description/champs/engagement.html.haml', type: :view do
let(:type_champ) { create(:type_de_champ_public, type_champ: :engagement) }
subject { render 'users/description/champs/engagement.html.haml', champ: champ }
context "when the value is on" do
let!(:champ) { create(:champ, type_de_champ: type_champ, value: "on").decorate }
it { is_expected.to have_selector("input[type='checkbox'][checked]") }
end
context "when the value is nil" do
let!(:champ) { create(:champ, type_de_champ: type_champ, value: nil).decorate }
it { is_expected.to have_selector("input[type='checkbox']") }
it { is_expected.not_to have_selector("input[type='checkbox'][checked]") }
end
end