Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to translate image_title and image_alt fields
- Loading branch information
Brice Sanchez
committed
Jul 24, 2015
1 parent
a747bfe
commit b22eab5
Showing
13 changed files
with
91 additions
and
17 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
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
14 changes: 14 additions & 0 deletions
14
images/db/migrate/20150430171341_translate_refinery_images.rb
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,14 @@ | ||
class TranslateRefineryImages < ActiveRecord::Migration | ||
def self.up | ||
Refinery::Image.create_translation_table!({ | ||
image_alt: :string, | ||
image_title: :string | ||
}, { | ||
:migrate_data => true | ||
}) | ||
end | ||
|
||
def self.down | ||
Refinery::Image.drop_translation_table! migrate_data: true | ||
end | ||
end |
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 |
---|---|---|
|
@@ -22,3 +22,7 @@ def factory_paths | |
end | ||
end | ||
end | ||
|
||
ActiveSupport.on_load(:active_record) do | ||
require 'globalize' | ||
end |
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
shared_context 'admin images tab' do | ||
|
||
let(:open_upload_dialog) { find('a', text: ::I18n.t('create_new_image', scope: 'refinery.admin.images.actions')).trigger(:click) } | ||
let(:select_upload) {} | ||
let(:initialize_context) {} | ||
let(:index_in_frame) {false} | ||
let(:dialog_frame_id) {'dialog_iframe'} | ||
let(:open_upload_dialog) { find('a', text: ::I18n.t('create_new_image', scope: 'refinery.admin.images.actions')).trigger(:click) } | ||
let(:select_upload) {} | ||
let(:initialize_context) {} | ||
let(:index_in_frame) {false} | ||
let(:dialog_frame_id) {'dialog_iframe'} | ||
let(:initial_path) { refinery.admin_images_path(view: %w(grid list).sample) } | ||
|
||
let(:index_item_selector) {'#records li'} | ||
let(:gridview_img_selector) {' > img'} | ||
let(:index_item_selector) {'#records li'} | ||
let(:gridview_img_selector) {' > img'} | ||
let(:gridview_title_selector) {'[tooltip]'} | ||
let(:gridview_alt_selector) {'[alt]'} | ||
let(:gridview_alt_selector) {'[alt]'} | ||
let(:listview_title_selector) {' > span.title'} | ||
let(:listview_alt_selector) {' > span.alt'} | ||
let(:listview_filename_selector) {' > span.preview'} | ||
|
||
end |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
shared_examples 'edits an image' do | ||
pending | ||
end | ||
end |
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,31 @@ | ||
shared_examples 'translates an image' do | ||
before do | ||
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :fr]) | ||
ensure_on(initial_path) | ||
end | ||
|
||
context "when in list view" do | ||
before do | ||
ensure_on(current_path + "?view=list") | ||
end | ||
|
||
it "can have a second locale added to it", focus: true do | ||
expect(page).to have_content("Beach") | ||
expect(page).to have_selector("a[href='/refinery/images/#{image.id}/edit']") | ||
|
||
click_link "Edit this image" | ||
|
||
within "#switch_locale_picker" do | ||
click_link "FR" | ||
end | ||
|
||
fill_in "Title", :with => "Titre de la première image" | ||
fill_in "Alt", :with => "Texte alternatif de la première image" | ||
|
||
click_button "Save" | ||
|
||
expect(page).to have_content("'Titre de la première image' was successfully updated.") | ||
expect(Refinery::Image.translation_class.count).to eq(1) | ||
end | ||
end | ||
end |