Commit c48ee460 authored by Diego de Araújo Martinez Camarinha's avatar Diego de Araújo Martinez Camarinha Committed by marcheing

Pass the locale for state action on AJAX

Signed-off-by: marcheing's avatarHeitor Reis <marcheing@gmail.com>
parent 1ece2045
......@@ -14,6 +14,5 @@
//= require jquery_ujs
//= require foundation
//= require turbolinks
//= require_tree .
$(function(){ $(document).foundation(); });
var state_select = function(event) {
function state_select(event) {
$.get('/states',
{ country: $('select#profile_country :selected').text(), locale: "<%= I18n.locale %>" },
{ country: $('select#profile_country :selected').text(), locale: $('#locale').val() },
function(data) { $('div#state_select').html(data); }
);
}
......
......@@ -239,6 +239,7 @@
</div>
</fieldset>
<% end %>
<%= hidden_field_tag('locale', I18n.locale) %>
</div>
<% content_for :footer do %>
......
......@@ -158,10 +158,12 @@ RSpec.describe ProfilesController, type: :controller do
describe 'states' do
render_views
let!(:country) { Carmen::Country.all.sample }
let(:params) { { country: country.name } }
let(:country) { Carmen::Country.all.sample }
let(:params) { { country: country.name, locale: I18n.locale } }
let(:carmen_locale) { Carmen.i18n_backend.locale }
before do
Carmen.i18n_backend.locale = I18n.locale.to_s.split('-').first
get :states, params: params
end
......@@ -172,6 +174,10 @@ RSpec.describe ProfilesController, type: :controller do
expect(response.body).to include CGI.escapeHTML subregion.name
end
end
after do
Carmen.i18n_backend.locale = carmen_locale
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment