Sha256: 7e974be77e72d80b405ed8a702503ce7db6837063f21898ace7ad55c1bead4d9
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
require 'spec_helper' require 'pry' RSpec.describe RailsAdmin::Config::Fields::Types::GlobalizeTabs do let(:translated_page) { Page.create!( slug: '2001', image: 'poster.png', title: '2001: Space odyssey', content: '<p>Visionary</p>' ) } let(:note) { Admin::Note.create(title: 'Fix bug with namespaces', image: 'urgent.png') } it 'renders all available locales as tabs' do visit '/page/new' expect(find('.globalize_tabs_type').find('.nav-tabs')).to have_content 'en cz ru' end describe 'localized data in correct tab' do it 'renders the default locale' do visit "/page/#{translated_page.id}/edit" within(".localized-pane-en-page-#{translated_page.id}") do expect(find_field('Title').value).to eq('2001: Space odyssey') expect(find_field('Content')).to have_content('<p>Visionary</p>') end end it 'renders cz locale' do Globalize.with_locale(:cz) do translated_page.title = '2001: Vesmírná odysea' translated_page.content = '<p>Vizionář</p>' translated_page.save! end visit "/page/#{translated_page.id}/edit" within(".localized-pane-cz-page-#{translated_page.id}") do expect(find_field('Title').value).to eq('2001: Vesmírná odysea') expect(find_field('Content')).to have_content('<p>Vizionář</p>') end end end it 'works correctly with namespaced models' do visit "/admin~note/#{note.id}/edit" expect(page).to have_css(".localized-pane-en-admin-note-#{note.id}") end it 'allows to set custom label name for translated attribute' do visit "/admin~note/#{note.id}/edit" within(".localized-pane-en-admin-note-#{note.id}") do expect(find('#admin_note_translations_attributes_0_title_field')).to have_content('Custom note title') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_admin_globalize_field-0.4.0 | spec/field_spec.rb |