rails-js-routes 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +80 -54
- data/app/assets/javascripts/routes.js +38 -5
- data/lib/rails/js/routes/version.rb +1 -1
- data/test/dummy/config/application.rb +1 -11
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/dummy/config/initializers/assets.rb +1 -0
- data/test/dummy/spec/javascripts/js_routes_spec.js +28 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46dede564808b8c4835cfb97ef7417449bbec856
|
4
|
+
data.tar.gz: fa16c441566a04db6b7ece491a4aaef918f2e56f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1732618ab809e15d4405c5942d90e5a208d8e62f01ce49a38132d1a4a6d1cc463bd292b9f53d64bf592d87c369ecfe4b9173bbb81bba1749f4a861499c5e5f18
|
7
|
+
data.tar.gz: f838a4ed2f0314f6d2a49f5a234bc895e5ed05d940252ee0ed237c70e26588aefe12f43ff600d277c15f5030ea1d81c89ea34156239ff101ddf743d505c23908
|
data/Gemfile.lock
CHANGED
@@ -7,33 +7,42 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionmailer (4.
|
11
|
-
actionpack (= 4.
|
12
|
-
actionview (= 4.
|
10
|
+
actionmailer (4.2.0)
|
11
|
+
actionpack (= 4.2.0)
|
12
|
+
actionview (= 4.2.0)
|
13
|
+
activejob (= 4.2.0)
|
13
14
|
mail (~> 2.5, >= 2.5.4)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
16
|
+
actionpack (4.2.0)
|
17
|
+
actionview (= 4.2.0)
|
18
|
+
activesupport (= 4.2.0)
|
19
|
+
rack (~> 1.6.0)
|
18
20
|
rack-test (~> 0.6.2)
|
19
|
-
|
20
|
-
|
21
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
22
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
23
|
+
actionview (4.2.0)
|
24
|
+
activesupport (= 4.2.0)
|
21
25
|
builder (~> 3.1)
|
22
26
|
erubis (~> 2.7.0)
|
23
|
-
|
24
|
-
|
27
|
+
rails-dom-testing (~> 1.0, >= 1.0.5)
|
28
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.1)
|
29
|
+
activejob (4.2.0)
|
30
|
+
activesupport (= 4.2.0)
|
31
|
+
globalid (>= 0.3.0)
|
32
|
+
activemodel (4.2.0)
|
33
|
+
activesupport (= 4.2.0)
|
25
34
|
builder (~> 3.1)
|
26
|
-
activerecord (4.
|
27
|
-
activemodel (= 4.
|
28
|
-
activesupport (= 4.
|
29
|
-
arel (~>
|
30
|
-
activesupport (4.
|
31
|
-
i18n (~> 0.
|
35
|
+
activerecord (4.2.0)
|
36
|
+
activemodel (= 4.2.0)
|
37
|
+
activesupport (= 4.2.0)
|
38
|
+
arel (~> 6.0)
|
39
|
+
activesupport (4.2.0)
|
40
|
+
i18n (~> 0.7)
|
32
41
|
json (~> 1.7, >= 1.7.7)
|
33
42
|
minitest (~> 5.1)
|
34
|
-
thread_safe (~> 0.
|
43
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
35
44
|
tzinfo (~> 1.1)
|
36
|
-
arel (
|
45
|
+
arel (6.0.0)
|
37
46
|
builder (3.2.2)
|
38
47
|
capybara (2.4.4)
|
39
48
|
mime-types (>= 1.16)
|
@@ -42,51 +51,66 @@ GEM
|
|
42
51
|
rack-test (>= 0.5.4)
|
43
52
|
xpath (~> 2.0)
|
44
53
|
cliver (0.3.2)
|
45
|
-
coveralls (0.7.
|
46
|
-
multi_json (~> 1.
|
47
|
-
rest-client (
|
48
|
-
simplecov (
|
49
|
-
term-ansicolor (
|
50
|
-
thor (
|
54
|
+
coveralls (0.7.9)
|
55
|
+
multi_json (~> 1.10)
|
56
|
+
rest-client (~> 1.7)
|
57
|
+
simplecov (~> 0.9.1)
|
58
|
+
term-ansicolor (~> 1.3)
|
59
|
+
thor (~> 0.19.1)
|
51
60
|
docile (1.1.5)
|
52
61
|
erubis (2.7.0)
|
62
|
+
globalid (0.3.3)
|
63
|
+
activesupport (>= 4.1.0)
|
53
64
|
hike (1.2.3)
|
54
|
-
i18n (0.
|
55
|
-
json (1.8.
|
65
|
+
i18n (0.7.0)
|
66
|
+
json (1.8.2)
|
67
|
+
loofah (2.0.1)
|
68
|
+
nokogiri (>= 1.5.9)
|
56
69
|
mail (2.6.3)
|
57
70
|
mime-types (>= 1.16, < 3)
|
58
71
|
mime-types (2.4.3)
|
59
|
-
mini_portile (0.6.
|
60
|
-
minitest (5.
|
72
|
+
mini_portile (0.6.2)
|
73
|
+
minitest (5.5.1)
|
61
74
|
multi_json (1.10.1)
|
62
|
-
|
75
|
+
netrc (0.10.2)
|
76
|
+
nokogiri (1.6.6.2)
|
63
77
|
mini_portile (~> 0.6.0)
|
64
|
-
poltergeist (1.
|
78
|
+
poltergeist (1.6.0)
|
65
79
|
capybara (~> 2.1)
|
66
80
|
cliver (~> 0.3.1)
|
67
81
|
multi_json (~> 1.0)
|
68
82
|
websocket-driver (>= 0.2.0)
|
69
|
-
rack (1.
|
70
|
-
rack-test (0.6.
|
83
|
+
rack (1.6.0)
|
84
|
+
rack-test (0.6.3)
|
71
85
|
rack (>= 1.0)
|
72
|
-
rails (4.
|
73
|
-
actionmailer (= 4.
|
74
|
-
actionpack (= 4.
|
75
|
-
actionview (= 4.
|
76
|
-
|
77
|
-
|
78
|
-
|
86
|
+
rails (4.2.0)
|
87
|
+
actionmailer (= 4.2.0)
|
88
|
+
actionpack (= 4.2.0)
|
89
|
+
actionview (= 4.2.0)
|
90
|
+
activejob (= 4.2.0)
|
91
|
+
activemodel (= 4.2.0)
|
92
|
+
activerecord (= 4.2.0)
|
93
|
+
activesupport (= 4.2.0)
|
79
94
|
bundler (>= 1.3.0, < 2.0)
|
80
|
-
railties (= 4.
|
81
|
-
sprockets-rails
|
82
|
-
|
83
|
-
|
84
|
-
|
95
|
+
railties (= 4.2.0)
|
96
|
+
sprockets-rails
|
97
|
+
rails-deprecated_sanitizer (1.0.3)
|
98
|
+
activesupport (>= 4.2.0.alpha)
|
99
|
+
rails-dom-testing (1.0.5)
|
100
|
+
activesupport (>= 4.2.0.beta, < 5.0)
|
101
|
+
nokogiri (~> 1.6.0)
|
102
|
+
rails-deprecated_sanitizer (>= 1.0.1)
|
103
|
+
rails-html-sanitizer (1.0.1)
|
104
|
+
loofah (~> 2.0)
|
105
|
+
railties (4.2.0)
|
106
|
+
actionpack (= 4.2.0)
|
107
|
+
activesupport (= 4.2.0)
|
85
108
|
rake (>= 0.8.7)
|
86
109
|
thor (>= 0.18.1, < 2.0)
|
87
|
-
rake (10.4.
|
88
|
-
rest-client (1.
|
89
|
-
mime-types (>= 1.16)
|
110
|
+
rake (10.4.2)
|
111
|
+
rest-client (1.7.2)
|
112
|
+
mime-types (>= 1.16, < 3.0)
|
113
|
+
netrc (~> 0.7)
|
90
114
|
simplecov (0.9.1)
|
91
115
|
docile (~> 1.1.0)
|
92
116
|
multi_json (~> 1.0)
|
@@ -97,22 +121,24 @@ GEM
|
|
97
121
|
multi_json (~> 1.0)
|
98
122
|
rack (~> 1.0)
|
99
123
|
tilt (~> 1.1, != 1.3.0)
|
100
|
-
sprockets-rails (2.2.
|
124
|
+
sprockets-rails (2.2.4)
|
101
125
|
actionpack (>= 3.0)
|
102
126
|
activesupport (>= 3.0)
|
103
127
|
sprockets (>= 2.8, < 4.0)
|
104
128
|
sqlite3 (1.3.10)
|
105
129
|
teaspoon (0.8.0)
|
106
130
|
railties (>= 3.2.5, < 5)
|
107
|
-
term-ansicolor (1.
|
108
|
-
tins (~> 0
|
109
|
-
thor (0.
|
131
|
+
term-ansicolor (1.3.0)
|
132
|
+
tins (~> 1.0)
|
133
|
+
thor (0.19.1)
|
110
134
|
thread_safe (0.3.4)
|
111
135
|
tilt (1.4.1)
|
112
|
-
tins (
|
136
|
+
tins (1.3.4)
|
113
137
|
tzinfo (1.2.2)
|
114
138
|
thread_safe (~> 0.1)
|
115
|
-
websocket-driver (0.
|
139
|
+
websocket-driver (0.5.1)
|
140
|
+
websocket-extensions (>= 0.1.0)
|
141
|
+
websocket-extensions (0.1.1)
|
116
142
|
xpath (2.0.0)
|
117
143
|
nokogiri (~> 1.3)
|
118
144
|
|
@@ -8,7 +8,18 @@
|
|
8
8
|
globalHelpers = {},
|
9
9
|
namespaceHooks = {},
|
10
10
|
data = {},
|
11
|
-
beforeAll = null
|
11
|
+
beforeAll = null,
|
12
|
+
isDOMElement;
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Helper function, returns true if o is a DOMElement
|
16
|
+
*/
|
17
|
+
function isDOMElement(el) {
|
18
|
+
return (
|
19
|
+
typeof HTMLElement === "object" ? el instanceof HTMLElement :
|
20
|
+
el && typeof el === "object" && el !== null && el.nodeType === 1 && typeof el.nodeName=== "string"
|
21
|
+
);
|
22
|
+
};
|
12
23
|
|
13
24
|
/*
|
14
25
|
* Singleton that stores functions to create your apps' structure
|
@@ -99,9 +110,19 @@
|
|
99
110
|
* Execute the actual controller action.
|
100
111
|
* e.g. will execute controller.users.index()
|
101
112
|
* when on #users/index
|
113
|
+
*
|
114
|
+
* It is also possible to supply a link with
|
115
|
+
* data-action, data-controller and data-namespace attributes
|
116
|
+
* to set Rails.config before execution
|
117
|
+
*
|
118
|
+
* Furthermore putting 'false' as first argument will only execute beforeAll()
|
102
119
|
*/
|
103
120
|
Rails.execute = function() {
|
104
121
|
|
122
|
+
var controllerName,
|
123
|
+
namespaceHook,
|
124
|
+
controller;
|
125
|
+
|
105
126
|
/*
|
106
127
|
* Make sure rails.js has been properly added to the layout
|
107
128
|
*/
|
@@ -111,10 +132,6 @@
|
|
111
132
|
'It seems like you forgot to add rails.js to your layouts\' header.'].join(' ');
|
112
133
|
}
|
113
134
|
|
114
|
-
var controllerName = this.config.controller,
|
115
|
-
namespaceHook,
|
116
|
-
controller;
|
117
|
-
|
118
135
|
/*
|
119
136
|
* Execute beforeAll() hook if defined
|
120
137
|
*/
|
@@ -122,6 +139,22 @@
|
|
122
139
|
beforeAll();
|
123
140
|
}
|
124
141
|
|
142
|
+
/*
|
143
|
+
* Set config if link is passed as first argument
|
144
|
+
*/
|
145
|
+
if (arguments.length == 1 && isDOMElement(arguments[0])) {
|
146
|
+
this.config.action = arguments[0].attributes['data-action'];
|
147
|
+
this.config.controller = arguments[0].attributes['data-controller'];
|
148
|
+
this.config.namespace = arguments[0].attributes['data-namespace'];
|
149
|
+
} else if (arguments[0] === false) {
|
150
|
+
/*
|
151
|
+
* Break if false if passed as first argument
|
152
|
+
*/
|
153
|
+
return;
|
154
|
+
}
|
155
|
+
|
156
|
+
controllerName = this.config.controller;
|
157
|
+
|
125
158
|
/*
|
126
159
|
* Take care of namespace (e.g. admin/users)
|
127
160
|
*/
|
@@ -6,17 +6,7 @@ Bundler.require(*Rails.groups)
|
|
6
6
|
|
7
7
|
module Dummy
|
8
8
|
class Application < Rails::Application
|
9
|
-
|
10
|
-
# Application configuration should go into files in config/initializers
|
11
|
-
# -- all .rb files in that directory are automatically loaded.
|
12
|
-
|
13
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
14
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
15
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
16
|
-
|
17
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
18
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
19
|
-
# config.i18n.default_locale = :de
|
9
|
+
config.active_support.test_order = :sorted
|
20
10
|
end
|
21
11
|
end
|
22
12
|
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
16
|
+
config.serve_static_files = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
@@ -1,3 +1,4 @@
|
|
1
1
|
Rails.application.config.assets.precompile += %w( teaspoon.css )
|
2
2
|
Rails.application.config.assets.precompile += %w( jasmine/1.3.1.js )
|
3
3
|
Rails.application.config.assets.precompile += %w( teaspoon-jasmine.js )
|
4
|
+
Rails.application.config.assets.precompile += %w( teaspoon-teaspoon.js )
|
@@ -162,5 +162,33 @@
|
|
162
162
|
Rails.execute();
|
163
163
|
expect(spies.namespaceHook).toHaveBeenCalled();
|
164
164
|
});
|
165
|
+
|
166
|
+
it('must set Rails.config if link supplied', function() {
|
167
|
+
// Set config normally set by view_helper
|
168
|
+
Rails.config = {
|
169
|
+
controller: 'entities',
|
170
|
+
action: 'new'
|
171
|
+
};
|
172
|
+
|
173
|
+
Rails.controller('admin/users', {
|
174
|
+
index: spies.adminUsersIndex
|
175
|
+
});
|
176
|
+
|
177
|
+
var configLink = document.createElement('a');
|
178
|
+
configLink.attributes['data-action'] = 'index';
|
179
|
+
configLink.attributes['data-controller'] = 'users';
|
180
|
+
configLink.attributes['data-namespace'] = 'admin';
|
181
|
+
|
182
|
+
Rails.execute(configLink);
|
183
|
+
|
184
|
+
expect(spies.adminUsersIndex).toHaveBeenCalled();
|
185
|
+
});
|
186
|
+
|
187
|
+
it('wont call controller action if Rails.execute called with false', function() {
|
188
|
+
Rails.execute(false);
|
189
|
+
expect(spies.usersIndex).not.toHaveBeenCalled();
|
190
|
+
Rails.execute();
|
191
|
+
expect(spies.usersIndex).toHaveBeenCalled();
|
192
|
+
});
|
165
193
|
});
|
166
194
|
})();
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-js-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Finn-Lenanrt Heemeyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -171,8 +171,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.0.14
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: A new approach to structure your javascript in non single-page Rails apps
|
178
178
|
test_files: []
|
179
|
+
has_rdoc:
|