Sha256: 589e80c543e9f651282f4360378372cc8bb667ab8e3052595f919a6412b1b505

Contents?: true

Size: 1.12 KB

Versions: 21

Compression:

Stored size: 1.12 KB

Contents

require 'rails_helper'

RSpec.shared_examples_for "ActiveAdmin::Localizers::ResourceLocalizer" do
  it "should use proper translation" do
    string = ActiveAdmin::Localizers::ResourceLocalizer.t(action, model: model, model_name: model_name)
    expect(string).to eq translation
  end

  it "should accessible via ActiveAdmin::Localizers" do
    resource = double(resource_label: model, resource_name: double(i18n_key: model_name))
    localizer = ActiveAdmin::Localizers.resource(resource)
    expect(localizer.t(action)).to eq translation
  end
end

RSpec.describe ActiveAdmin::Localizers::ResourceLocalizer do
  let(:action) { 'new_model' }
  let(:model) { 'Comment' }
  let(:model_name) { 'comment' }

  it_behaves_like "ActiveAdmin::Localizers::ResourceLocalizer" do
    let(:translation) { 'New Comment' }
  end

  describe "model action specified" do
    around do |example|
      with_translation active_admin: {resources: {comment: {new_model: 'Write comment'}}} do
        example.call
      end
    end

    it_behaves_like "ActiveAdmin::Localizers::ResourceLocalizer" do
      let(:translation) { 'Write comment' }
    end
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
activeadmin-rails-1.7.1 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-rails-1.7.0 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-rb-1.6.0 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-rb-1.5.2 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-rb-1.5.1 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-rb-1.5.0 spec/unit/localizers/resource_localizer_spec.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/localizers/resource_localizer_spec.rb
activeadmin-rb-1.4.0 spec/unit/localizers/resource_localizer_spec.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/localizers/resource_localizer_spec.rb
activeadmin-1.3.1 spec/unit/localizers/resource_localizer_spec.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/localizers/resource_localizer_spec.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/localizers/resource_localizer_spec.rb
activeadmin-1.3.0 spec/unit/localizers/resource_localizer_spec.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/localizers/resource_localizer_spec.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/localizers/resource_localizer_spec.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/localizers/resource_localizer_spec.rb
activeadmin-1.2.1 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-1.2.0 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-1.1.0 spec/unit/localizers/resource_localizer_spec.rb
activeadmin-1.0.0 spec/unit/localizers/resource_localizer_spec.rb