Sha256: 30a9891eb4bdbd16af8599c0fc7346c2ca0a13a82db8d7e6917f53c710b4d125

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

RSpec.describe Breadcrumby::Viewer, '.i18n_action_name' do
  subject { described_class.new object, options, view }

  let!(:object)  { build :school }
  let!(:options) { {} }
  let!(:view)    { double }
  let!(:action)  { :edit }

  before do
    allow(I18n).to receive(:t).with(:edit) { 'edit' }

    allow(I18n).to receive(:t).with(
      'actions.edit.name', scope: [:breadcrumby], default: 'edit'
    ) { 'root || edit' }

    allow(I18n).to receive(:t).with(
      'actions.edit.name', scope: [:breadcrumby, 'school'], default: 'root || edit'
    ) { 'translation' }
  end

  it 'returns a name for object fetched from i18n with root fallback' do
    expect(subject.i18n_action_name(object, action)).to eq 'translation'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
breadcrumby-0.1.0 spec/lib/breadcrumby/models/viewer/i18n_action_name_spec.rb