Sha256: 6ec54c2874b4f8b09c65fa071c90ebc8d5d18962ed35db0b1e103fe9643ceb1a

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe LostInTranslations::ActiveRecord do

  context "when building a resource" do
    before do
      @user_class = Class.new(ActiveRecord::Base) do
        self.table_name = 'users'

        include LostInTranslations::ActiveRecord

        translate :title, :first_name

        def translation_data
          @translation_data ||= {
            en: { first_name: 'Jon', last_name: 'Snow' },
            fr: { first_name: 'Jean', last_name: 'Neige' }
          }
        end
      end

      @user = @user_class.new(title: 'Cavaleiro', first_name: 'Joao', last_name: 'Neve')
    end

    it_behaves_like "the readme example"
  end

  context "When finding a resource" do
    before do
      @user_class = Class.new(ActiveRecord::Base) do
        self.table_name = 'users'

        include LostInTranslations::ActiveRecord

        translate :title, :first_name

        def translation_data
          @translation_data ||= {
            en: { first_name: 'Jon', last_name: 'Snow' },
            fr: { first_name: 'Jean', last_name: 'Neige' }
          }
        end
      end

      @user = @user_class.first
    end

    it_behaves_like "the readme example"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lost_in_translations-1.4.0 spec/lost_in_translations/active_record_spec.rb