Skip to content

Commit

Permalink
fixed bug caused by params returning in reverse in crystal and amber …
Browse files Browse the repository at this point in the history
…params rewrite.
  • Loading branch information
elorest committed Mar 30, 2018
1 parent 39009a9 commit e3f3d15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions spec/jasper_helpers/forms_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe JasperHelpers::Forms do
end

it "creates with content" do
expected = "<label for=\"name\" id=\"name_label\"><input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/><input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\"/>Name</label>"
expected = "<label for=\"name\" id=\"name_label\"><input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\"/><input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/>Name</label>"
label(:name) do
check_box(:allowed)
end.should eq(expected)
Expand Down Expand Up @@ -133,22 +133,22 @@ describe JasperHelpers::Forms do

describe "#check_box" do
it "creates a check_box with yes/no" do
expected = "<input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"no\"/><input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"yes\"/>"
expected = "<input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"yes\"/><input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"no\"/>"
check_box(:allowed, checked_value: "yes", unchecked_value: "no").should eq(expected)
end

it "creates a check_box with only value" do
expected = "<input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/><input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\"/>"
expected = "<input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\"/><input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/>"
check_box(:allowed).should eq(expected)
end

it "marks box as checked" do
expected = "<input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/><input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\" checked=\"checked\"/>"
expected = "<input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\" checked=\"checked\"/><input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/>"
check_box(:allowed, checked: true).should eq(expected)
end

it "marks box as not checked" do
expected = "<input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/><input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\"/>"
expected = "<input type=\"checkbox\" name=\"allowed\" id=\"allowed\" value=\"1\"/><input type=\"hidden\" name=\"allowed\" id=\"allowed_default\" value=\"0\"/>"
check_box(:allowed, checked: false).should eq(expected)
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/jasper_helpers/forms.cr
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ module JasperHelpers::Forms
end

String.build do |str|
str << hidden_field(name, value: unchecked_value, id: "#{options_hash[:id]}_default")
str << input_field(type: :checkbox, options: options_hash)
str << hidden_field(name, value: unchecked_value, id: "#{options_hash[:id]}_default")
end
end

Expand Down

0 comments on commit e3f3d15

Please sign in to comment.