mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
Test for calling callback for namespaced controller
This commit is contained in:
parent
30caabddcb
commit
6b02d8b6fa
11 changed files with 42 additions and 9 deletions
16
Rakefile
16
Rakefile
|
@ -9,8 +9,20 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|||
end
|
||||
|
||||
|
||||
desc "Run tests"
|
||||
desc "Run all tests"
|
||||
task :test do
|
||||
puts "Testing..."
|
||||
sh "bundle exec rake spec"
|
||||
end
|
||||
|
||||
|
||||
desc "Run callback tests"
|
||||
task :test_callbacks do
|
||||
sh "rspec ./spec/callback_spec.rb"
|
||||
end
|
||||
|
||||
|
||||
desc "Run generator tests"
|
||||
task :test_generators do
|
||||
sh "rspec ./spec/generator_spec.rb"
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ module Paloma
|
|||
# js_callback :params => {}
|
||||
#
|
||||
def js_callback options = {}, extras = {}
|
||||
default_callback = "#{controller_name}/#{action_name}"
|
||||
default_callback = "#{controller_path}/#{action_name}"
|
||||
params = {}
|
||||
|
||||
if options.is_a? Hash
|
||||
|
@ -33,7 +33,7 @@ module Paloma
|
|||
|
||||
elsif options.is_a? Symbol
|
||||
params = extras[:params]
|
||||
callback = "#{controller_name}/#{options}"
|
||||
callback = "#{controller_path}/#{options}"
|
||||
|
||||
elsif options.nil? || options.is_a?(TrueClass)
|
||||
callback = default_callback
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'spec_helper'
|
||||
=begin
|
||||
|
||||
feature 'Callbacks' do
|
||||
|
||||
it 'should execute articles/new callback', :js => true do
|
||||
|
@ -62,5 +62,12 @@ feature 'Callbacks' do
|
|||
|
||||
page.has_selector?('#from-articles-edit-callback').should == true
|
||||
end
|
||||
|
||||
|
||||
it 'should execute sample_namespace/categories/index callback', :js => true do
|
||||
1.upto(10).each { |i| Category.create :name => "Category #{i}" }
|
||||
|
||||
visit sample_namespace_categories_path
|
||||
page.has_selector?('#from-categories-index').should == true
|
||||
end
|
||||
end
|
||||
=end
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
//= require ./paloma
|
||||
//= require ./articles/callbacks
|
||||
//= require ./articles/_callbacks.js
|
||||
//= require ./sample_namespace/_callbacks.js
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
//= require ./categories/_callbacks.js
|
|
@ -0,0 +1 @@
|
|||
//= require_tree .
|
|
@ -0,0 +1,3 @@
|
|||
Paloma.callbacks['sample_namespace/categories/index'] = function(params){
|
||||
$('body').append($("<div id='from-categories-index'></div>"));
|
||||
};
|
|
@ -0,0 +1,5 @@
|
|||
<% @categories.each do |category| %>
|
||||
<div>
|
||||
<%= category.name %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -56,7 +56,7 @@ end
|
|||
module SampleNamespace
|
||||
class CategoriesController < ApplicationController
|
||||
def index
|
||||
raise controller_path.inspect
|
||||
@categories = Category.all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,10 @@ app.initialize!
|
|||
# Routes
|
||||
app.routes.draw do
|
||||
resources :articles, :controller => 'Articles'
|
||||
resources :categories, :module => 'SampleNamespace'
|
||||
|
||||
namespace :sample_namespace do
|
||||
resources :categories
|
||||
end
|
||||
end
|
||||
|
||||
require "#{Paloma.root}/spec/sample_app/models"
|
||||
|
|
Loading…
Reference in a new issue