-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
1 parent
a747bfe
commit 54f4018
Showing
11 changed files
with
84 additions
and
18 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
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,27 @@ | ||
shared_examples 'edits an image' do | ||
pending | ||
end | ||
let!(:image) { FactoryGirl.create(:image) } | ||
|
||
describe "translate", focus: true do | ||
before do | ||
allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :fr]) | ||
end | ||
|
||
it "can have a second locale added to it" do | ||
visit refinery.admin_images_path | ||
expect(page).to have_content("Refinery Is Awesome") | ||
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 => "Première image" | ||
click_button "Save" | ||
|
||
expect(page).to have_content("'Première image' was successfully updated.") | ||
expect(Image.translation_class.count).to eq(1) | ||
end | ||
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