Skip to content

Commit

Permalink
Fix format of price input in products/new.html.erb
Browse files Browse the repository at this point in the history
  • Loading branch information
laurens authored and radar committed Oct 11, 2013
1 parent 97e11e7 commit 15bec0f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/products/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<div class="four columns">
<%= f.field_container :price do %>
<%= f.label :price, Spree.t(:master_price) %> <span class="required">*</span><br />
<%= f.text_field :price, :class => 'fullwidth' %>
<%= f.text_field :price, :value => number_to_currency(@product.price, :unit => ''), :class => 'fullwidth' %>
<%= f.error_message_on :price %>
<% end %>
</div>
Expand Down
35 changes: 35 additions & 0 deletions backend/spec/features/admin/products/products_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,40 @@ def build_option_type_with_values(name, values)
page.should have_content("Name can't be blank")
end

context "using a locale with a different decimal format " do
before do
# change English locale’s separator and delimiter to match 19,99 format
I18n.backend.store_translations(:en,
:number => {
:currency => {
:format => {
:separator => ",",
:delimiter => "."
}
}
})
end

after do
# revert changes to English locale
I18n.backend.store_translations(:en,
:number => {
:currency => {
:format => {
:separator => ".",
:delimiter => ","
}
}
})
end

it "should show localized price value on validation errors", :js => true do
fill_in "product_price", :with => "19,99"
click_button "Create"
find('input#product_price').value.should == '19,99'
end
end

# Regression test for #2097
it "can set the count on hand to a null value", :js => true do
fill_in "product_name", :with => "Baseball Cap"
Expand All @@ -220,6 +254,7 @@ def build_option_type_with_values(name, values)
page.should have_content("successfully updated!")
end
end


context "cloning a product", :js => true do
it "should allow an admin to clone a product" do
Expand Down

0 comments on commit 15bec0f

Please sign in to comment.