jcontroller 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 22c4aaa4a7e3d6508cdfbfd704f751a684a228df
4
- data.tar.gz: 91bf54f58ab80341995d6e5313ba1224956c772b
3
+ metadata.gz: dd4eddc629591228381b3f2e89830d0b4dfad727
4
+ data.tar.gz: e9e32d5f448c8d123120da86e1ccb90b05024675
5
5
  SHA512:
6
- metadata.gz: 3bd0f42b2f358a68c6a5a9b7bee0ada5e31a6aed48522e0cd9d78a09246b84ad189e9083ad89d6dfdf40317255d0f910ca2565b48786321ef103388f6cb29570
7
- data.tar.gz: 2e9d1744c7b07e75ca7c03a944a517ea565148dac4c2d68767302ae9ae73877f8131614abd4a112ca19b187263f13d790a24ddda7f2fe12181708c7b3186d1c5
6
+ metadata.gz: 75409726a27d522e8f362def93c1bec0bb4b970dc0e049f91172ce3657f54e95105b4295631b8478771d53fc44499059c7120d29fa4d49aebdb40dbadf8c5ae6
7
+ data.tar.gz: 96cdec26675bc6f59096186803ffb9ce266c9befb065e7c2e1e1082b5ae7d00c525c22496059601ba46348900ce3ba9e989e9a61cabc90aba28b1e2897eee437
@@ -52,9 +52,11 @@ module Jcontroller
52
52
  end
53
53
 
54
54
  def jcontroller_params(action)
55
- with_format :js do
56
- if lookup_context.template_exists? action.params_template_path
57
- view_context.render(:template => action.params_template_path)
55
+ if formats.first == :html
56
+ with_format :js do
57
+ if lookup_context.template_exists? action.params_template_path
58
+ view_context.render(:template => action.params_template_path)
59
+ end
58
60
  end
59
61
  end
60
62
  end
@@ -1,3 +1,3 @@
1
1
  module Jcontroller
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -4,9 +4,9 @@
4
4
  //= require_tree .
5
5
 
6
6
  test_append_selector = '#test_append';
7
- test_append = function(controller_namespace, filter, params) {
7
+ test_append = function(controller_namespace, filter, format, params) {
8
8
  var $div = $(document.createElement('div'));
9
- $div.attr("filter", controller_namespace + "/" + 'html' + "/" + filter);
9
+ $div.attr("filter", controller_namespace + "/" + format + "/" + filter);
10
10
  $div.append(params.s);
11
11
  $(test_append_selector).append($div);
12
12
  };
@@ -16,7 +16,7 @@ create_routes = function(controller_path, extend) {
16
16
  $.each(filters, function(index, filter) {
17
17
  hash[format][filter] = function(params, state) {
18
18
  if (this.params.s === params.s && this.state.action_name === state.action_name) {
19
- test_append(controller_path, filter, this.params);
19
+ test_append(controller_path, filter, format, this.params);
20
20
  }
21
21
  }
22
22
  });
@@ -26,6 +26,9 @@ create_routes = function(controller_path, extend) {
26
26
  hash.html.state = function() {
27
27
  $(test_append_selector).html(JSON.stringify(this.state));
28
28
  };
29
+ hash.js.parameters_template = function() {
30
+ test_append(controller_path, 'parameters_template', "js", this.params);
31
+ };
29
32
  set_basic_filters('html', ["before", "after", "index", "redirect", "redirect_simple",
30
33
  "manually_execute", "manual_parameters", "parameters_template"]);
31
34
  set_basic_filters('js', ["before", "after", "index"]);
@@ -11,11 +11,10 @@ class UsersController < ApplicationController
11
11
  end
12
12
 
13
13
  def parameters_template
14
- @parameter_string = "parameter template"
14
+ @parameter_string = "parameter template #{formats.first}"
15
15
  end
16
16
 
17
17
  def stopped
18
- Jcontroller.ajax = !params[:ajax_off]
19
18
  js false
20
19
  end
21
20
  def redirect
@@ -0,0 +1 @@
1
+ <%= link_to "ajax link", parameters_template_users_path, remote: true, onclick: "$(test_append_selector).empty();" %>
@@ -0,0 +1 @@
1
+ json.s @parameter_string
@@ -1 +1 @@
1
- json.s @parameter_string
1
+ json.s @parameter_string + "_params"
@@ -9,12 +9,14 @@ feature 'invoke correct filter', :js => true do
9
9
  "#{controller_namespace}/#{format}/#{filter}"
10
10
  end
11
11
 
12
- def filters(controller_namespace, action, parent_namespaces=%w[application])
13
- controller_namespaces = parent_namespaces + [controller_namespace]
12
+ def filters(controller_namespace, action, options={})
13
+ options = options.reverse_merge({ :parent_namespaces => %w[application], :format => "html" })
14
+
15
+ controller_namespaces = options[:parent_namespaces] + [controller_namespace]
14
16
  filters = []
15
- filters += controller_namespaces.map {|controller_namespace| filter_namespace(controller_namespace, "before") }
16
- filters += controller_namespaces.map {|controller_namespace| filter_namespace(controller_namespace, action) }
17
- filters + controller_namespaces.map {|controller_namespace| filter_namespace(controller_namespace, "after") }.reverse
17
+ filters += controller_namespaces.map {|controller_namespace| filter_namespace(controller_namespace, "before", options[:format]) }
18
+ filters += controller_namespaces.map {|controller_namespace| filter_namespace(controller_namespace, action, options[:format]) }
19
+ filters + controller_namespaces.map {|controller_namespace| filter_namespace(controller_namespace, "after", options[:format]) }.reverse
18
20
  end
19
21
 
20
22
  def test_elements(filters, parameters="")
@@ -59,7 +61,7 @@ feature 'invoke correct filter', :js => true do
59
61
  end
60
62
  scenario 'with superclassed controller' do
61
63
  visit superusers_path
62
- test_elements filters('superusers', "index", %w[application users])
64
+ test_elements filters('superusers', "index", { :parent_namespaces => %w[application users]})
63
65
  end
64
66
  scenario 'with empty parent controller' do
65
67
  visit empty_parents_path
@@ -106,12 +108,20 @@ feature 'invoke correct filter', :js => true do
106
108
  end
107
109
  scenario 'with parameters template' do
108
110
  visit parameters_template_users_path
109
- test_elements filters('users', "parameters_template"), "parameter template"
111
+ test_elements filters('users', "parameters_template"), "parameter template html_params"
110
112
  end
111
113
 
112
114
  context "with ajax" do
115
+ before :each do
116
+ Jcontroller.ajax = true
117
+ end
118
+ after :each do
119
+ Jcontroller.ajax = nil
120
+ end
121
+
113
122
  scenario "ajax off" do
114
- visit stopped_users_path(ajax_off: true)
123
+ Jcontroller.ajax = nil
124
+ visit stopped_users_path
115
125
  click_link "ajax link"
116
126
  wait_for_ajax
117
127
  test_no_elements
@@ -121,7 +131,14 @@ feature 'invoke correct filter', :js => true do
121
131
  visit stopped_users_path
122
132
  click_link "ajax link"
123
133
  wait_for_ajax
124
- test_elements filters('users', "index"), "ajax parameter"
134
+ test_elements filters('users', "index", { :format => "js"}), "ajax parameter"
135
+ end
136
+
137
+ scenario "with _params template existing" do
138
+ visit parameters_template_users_path
139
+ click_link "ajax link"
140
+ wait_for_ajax
141
+ test_elements filters('users', "parameters_template", { :format => "js"}), "parameter template js"
125
142
  end
126
143
  end
127
144
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcontroller
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Chung
@@ -182,6 +182,7 @@ files:
182
182
  - spec/fake_app/app/views/users/manually_execute.html.erb
183
183
  - spec/fake_app/app/views/users/no_action.html.erb
184
184
  - spec/fake_app/app/views/users/parameters_template.html.erb
185
+ - spec/fake_app/app/views/users/parameters_template.js.jbuilder
185
186
  - spec/fake_app/app/views/users/parameters_template_params.js.jbuilder
186
187
  - spec/fake_app/app/views/users/redirect_params.js.jbuilder
187
188
  - spec/fake_app/app/views/users/state.html.erb
@@ -237,6 +238,7 @@ test_files:
237
238
  - spec/fake_app/app/views/users/manually_execute.html.erb
238
239
  - spec/fake_app/app/views/users/no_action.html.erb
239
240
  - spec/fake_app/app/views/users/parameters_template.html.erb
241
+ - spec/fake_app/app/views/users/parameters_template.js.jbuilder
240
242
  - spec/fake_app/app/views/users/parameters_template_params.js.jbuilder
241
243
  - spec/fake_app/app/views/users/redirect_params.js.jbuilder
242
244
  - spec/fake_app/app/views/users/state.html.erb