jskit_rails 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcd9fbda4dcb8214247e55f4b44a5cc97e9b5d83
|
4
|
+
data.tar.gz: 645875d832923ce32348206255e18f544df2f486
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f0ce3d5b2cf5f534c142a53db851957cd1f7025853106e4266e854d026cb89f993df5097c13b6512601dc901e56cc1d7d697e83ec30c6dbcfac8b7285892d17
|
7
|
+
data.tar.gz: 00f8b09e5ec97a0ebe0f40406be07e20a33969cd4dfd81366586b9aa8eca0d3a0f7d5c1267b2f90c7b0976920b7eceeb010f28d5a55100a4d99ddd6445f29243
|
@@ -23,7 +23,7 @@ ApplicationController.class_eval do
|
|
23
23
|
[
|
24
24
|
JskitRails.configuration.app_namespace,
|
25
25
|
"Dispatcher",
|
26
|
-
|
26
|
+
%Q(trigger("#{[event_namespace, "controller", controller_name, action_name].compact.join(":")}"#{JSKit.action_payload});)
|
27
27
|
].join(".")
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ ApplicationController.class_eval do
|
|
31
31
|
[
|
32
32
|
JskitRails.configuration.app_namespace,
|
33
33
|
"Dispatcher",
|
34
|
-
|
34
|
+
%Q(trigger("#{[event_namespace, "controller", controller_name, "all"].compact.join(":")}"#{JSKit.controller_payload});)
|
35
35
|
].join(".")
|
36
36
|
end
|
37
37
|
|
@@ -40,18 +40,10 @@ ApplicationController.class_eval do
|
|
40
40
|
[
|
41
41
|
JskitRails.configuration.app_namespace,
|
42
42
|
"Dispatcher",
|
43
|
-
|
43
|
+
%Q(trigger("#{[event_namespace, "controller", "application", "all"].compact.join(":")}"#{JSKit.app_payload});)
|
44
44
|
].join(".")
|
45
45
|
end
|
46
46
|
|
47
|
-
def event_name(controller, action)
|
48
|
-
[event_namespace, "controller", controller, action].compact.join(":")
|
49
|
-
end
|
50
|
-
|
51
|
-
def event_trigger(event, payload)
|
52
|
-
%Q(trigger("#{event}"#{JSKit.controller_payload});)
|
53
|
-
end
|
54
|
-
|
55
47
|
def payload_js(payload)
|
56
48
|
payload.empty? ? "" : ", #{payload.map(&:to_json).join(', ')}"
|
57
49
|
end
|
@@ -63,8 +55,6 @@ ApplicationController.class_eval do
|
|
63
55
|
:payload_js,
|
64
56
|
:application_event,
|
65
57
|
:action_event,
|
66
|
-
:event_name,
|
67
|
-
:event_trigger,
|
68
58
|
:controller_event)
|
69
59
|
end
|
70
60
|
|
@@ -28,19 +28,6 @@ describe ApplicationController, type: :controller do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
describe "#event_name" do
|
32
|
-
it "returns the event name" do
|
33
|
-
expect(ApplicationController::JSKit.send(:event_name, "test_controller", "test_action")).to eq("controller:test_controller:test_action")
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with namespace" do
|
37
|
-
it "returns the controller event name prefixed with the namespace" do
|
38
|
-
allow(ApplicationController::JSKit).to receive(:event_namespace) { "test" }
|
39
|
-
expect(ApplicationController::JSKit.send(:event_name, "test_controller", "test_action")).to eq("test:controller:test_controller:test_action")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
31
|
describe "#jskit" do
|
45
32
|
it "returns a script tag with the global event and the controller event" do
|
46
33
|
subject = ApplicationController.new
|
@@ -49,6 +36,7 @@ describe ApplicationController, type: :controller do
|
|
49
36
|
application_event = ApplicationController::JSKit.send(:application_event)
|
50
37
|
controller_event = ApplicationController::JSKit.send(:controller_event)
|
51
38
|
action_event = ApplicationController::JSKit.send(:action_event)
|
39
|
+
|
52
40
|
expect(subject.jskit).to eq(subject.view_context.javascript_tag([application_event, controller_event, action_event].join("\n")))
|
53
41
|
end
|
54
42
|
end
|