Sha256: cb43979217d7692fbe4955f1261828f25de8f9afdcb63c80bbfe3d6a50e2e3ac

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

require 'coffee-script'

class Netzke::TestingController < ActionController::Base
  before_action :set_locale

  def components
    component_name = params[:class].gsub("::", "_").underscore
    render :inline => "<%= netzke :#{component_name}, :class_name => '#{params[:class]}', :height => #{params[:height] || 400} %>",
           :layout => true
  end

  def specs
    coffee = spec_file(params[:name])
    render js: CoffeeScript.compile(coffee)
  end

  private

  def set_locale
    # if params[:locale] is nil then I18n.default_locale will be used
    I18n.locale = params[:locale]
  end

  def spec_file(name)
    spec_root = Pathname.new(Netzke::Testing.spec_root || Rails.root)

    path = spec_root.join "spec/features/javascripts/#{name}_spec.js.coffee"

    if !File.exists?(File.expand_path(path, __FILE__))
      path = spec_root.join "spec/features/javascripts/#{name}.js.coffee"
    end

    File.read(File.expand_path(path, __FILE__))
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netzke-testing-6.5.0.0 app/controllers/netzke/testing_controller.rb
netzke-testing-6.5.0.0.rc1 app/controllers/netzke/testing_controller.rb