-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix translating Public Body Headings
Fixes submission of form containing both existing and new translations
- Loading branch information
1 parent
d389952
commit 8e5806f
Showing
7 changed files
with
267 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="tab-pane" id="div-locale-<%=locale.to_s%>"> | ||
<div class="control-group"> | ||
<%= t.hidden_field :locale, :value => locale.to_s %> | ||
<label for="<%= form_tag_id(t.object_name, :name, locale) %>" class="control-label">name</label> | ||
<div class="controls"> | ||
<%= t.text_field :name, :id => form_tag_id(t.object_name, :name, locale), :class => "span4" %> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
require File.expand_path(File.dirname(__FILE__) + '/alaveteli_dsl') | ||
|
||
describe 'Editing a Public Body Heading' do | ||
before do | ||
AlaveteliConfiguration.stub!(:skip_admin_auth).and_return(false) | ||
|
||
confirm(:admin_user) | ||
@admin = login(:admin_user) | ||
@heading = FactoryGirl.create(:public_body_heading) | ||
end | ||
|
||
it 'can edit the default locale' do | ||
@admin.visit edit_admin_heading_path(@heading) | ||
@admin.fill_in 'public_body_heading_name__en', :with => 'New Heading EN' | ||
@admin.click_button 'Save' | ||
|
||
@heading.reload | ||
expect(@heading.name).to eq('New Heading EN') | ||
end | ||
|
||
it 'can add a translation for a single locale' do | ||
expect(@heading.find_translation_by_locale('fr')).to be_nil | ||
|
||
@admin.visit edit_admin_heading_path(@heading) | ||
@admin.fill_in 'public_body_heading_translations_attributes_fr_name__fr', :with => 'New Heading FR' | ||
@admin.click_button 'Save' | ||
|
||
@heading.reload | ||
I18n.with_locale(:fr) do | ||
expect(@heading.name).to eq('New Heading FR') | ||
end | ||
end | ||
|
||
it 'can add a translation for multiple locales' do | ||
# Add FR translation | ||
expect(@heading.find_translation_by_locale('fr')).to be_nil | ||
@admin.visit edit_admin_heading_path(@heading) | ||
@admin.fill_in 'public_body_heading_translations_attributes_fr_name__fr', :with => 'New Heading FR' | ||
@admin.click_button 'Save' | ||
|
||
# Add ES translation | ||
expect(@heading.find_translation_by_locale('es')).to be_nil | ||
@admin.visit edit_admin_heading_path(@heading) | ||
@admin.fill_in 'public_body_heading_translations_attributes_es_name__es', :with => 'New Heading ES' | ||
@admin.click_button 'Save' | ||
|
||
@heading.reload | ||
I18n.with_locale(:fr) do | ||
expect(@heading.name).to eq('New Heading FR') | ||
end | ||
|
||
I18n.with_locale(:es) do | ||
expect(@heading.name).to eq('New Heading ES') | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.