Sha256: c8019d5aecf517aba98654d0faf1c043c62147cfd47e58a81515549324c51319

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

require 'active_record'
require 'action_controller/railtie'
require 'action_view/railtie'

# database
ActiveRecord::Base.configurations = { 'test' => { :adapter => 'sqlite3', :database => ':memory:' } }
ActiveRecord::Base.establish_connection 'test'

# config
app = Class.new(Rails::Application)
app.config.secret_token = "aoijg543oi2u88923j4fnvfjt529hg92"
app.config.session_store :cookie_store, :key => "_exvo_globalize_session"
app.config.active_support.deprecation = :log
app.config.i18n.default_locale = :en
app.initialize!

# application controller
class ApplicationController < ActionController::Base
  def require_admin
     redirect_to '/403.html', :status => 403 unless @current_user && @current_user.admin?
  end
end

# custom authentication
I18n::Backend::GlobalizeStore.authenticator = proc {
  require_admin
}

# migration
class CreateGlobalizeTranslations < ActiveRecord::Migration
  def self.up
    create_table :globalize_translations do |t|
      t.string :locale
      t.string :key
      t.text :value
      t.text :interpolations
      t.boolean :is_proc, :default => false
      t.timestamps
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
exvo_globalize-0.1.0 spec/app.rb
exvo_globalize-0.0.2 spec/app.rb