clever-ruby 0.13.0 → 0.13.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/clever-ruby/api_resource.rb +9 -1
- data/lib/clever-ruby/school_admin.rb +2 -0
- data/lib/clever-ruby/version.rb +1 -1
- data/test/unit/event_test.rb +45 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3248341c0c2b2897a297a4b47d4254f1521c5247
|
4
|
+
data.tar.gz: cc02fa1d0c39afb6f63af754eed6e131143a3234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a733af1ed14ff21d62c6bb8c6b4700a5f4c3a8c6d600cbab487a3b6fba9ed149415a0c7946860aded98e11bc51dcf5ea2775f5e47251f14d7d3a6a7f4c5c630
|
7
|
+
data.tar.gz: 1725a84c6ceb827d63eb66605fd9f1ce00f605ae121535c2c84c661af8cc0d5e866c91f8d4ac503ccc09cf7ee522896614981f85d8fed750e034fd4d81557d09
|
data/CHANGELOG.md
CHANGED
@@ -29,6 +29,14 @@ module Clever
|
|
29
29
|
# @api private
|
30
30
|
# @return [String] URI corresponding to a resource
|
31
31
|
attr_reader :uri
|
32
|
+
|
33
|
+
# Get the event name corresponding to a resource
|
34
|
+
#
|
35
|
+
# For some events, event type names have an inconsistent format with plurals and URIs.
|
36
|
+
# For example, SchoolAdmin events are "schooladmins"
|
37
|
+
# @api private
|
38
|
+
# @return [String] event type name of a resource
|
39
|
+
attr_reader :event_name
|
32
40
|
end
|
33
41
|
|
34
42
|
# Registers valid API resources
|
@@ -70,7 +78,7 @@ module Clever
|
|
70
78
|
def self.named(name)
|
71
79
|
name = name.to_s.downcase
|
72
80
|
matching = resources.select do |res|
|
73
|
-
(name == res.shortname) || (name == res.plural)
|
81
|
+
(name == res.shortname) || (name == res.plural) || (name == res.event_name)
|
74
82
|
end
|
75
83
|
return nil if matching.empty?
|
76
84
|
matching.first
|
data/lib/clever-ruby/version.rb
CHANGED
data/test/unit/event_test.rb
CHANGED
@@ -2,41 +2,56 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
# test events resource
|
4
4
|
describe Clever::Event do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
describe 'section events' do
|
6
|
+
before do
|
7
|
+
@event = Clever::Event.construct_from(
|
8
|
+
type: 'sections.created',
|
9
|
+
data: {
|
10
|
+
object: { id: '512bb9f2ca5e6fa77506133f' }
|
11
|
+
},
|
12
|
+
id: '512bb9f2ca5e6fa775061340'
|
13
|
+
)
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
@updated_event = Clever::Event.construct_from(
|
16
|
+
type: 'sections.updated',
|
17
|
+
data: {
|
18
|
+
object: { id: '510980c2923bcbba1f0ce5dd' },
|
19
|
+
previous_attributes: {
|
20
|
+
teacher: '510980a6923bcbba1f0cb500',
|
21
|
+
last_modified: '2013-03-11T15:38:58.558Z'
|
22
|
+
}
|
23
|
+
},
|
24
|
+
id: '514767bf80833fb55b1c2dd7'
|
25
|
+
)
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
it 'creates a clever object for the object the event is about' do
|
29
|
+
@event.object.must_be_instance_of Clever::Section
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
it 'knows what action the event is about (created/updated/deleted)' do
|
33
|
+
@event.action.must_equal 'created'
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns an empty hash if there aren't previous attributes" do
|
37
|
+
@event.previous_attributes.must_equal {}
|
38
|
+
end
|
34
39
|
|
35
|
-
|
36
|
-
|
40
|
+
it "has an event's previous attributes" do
|
41
|
+
@updated_event.previous_attributes[:teacher].must_equal '510980a6923bcbba1f0cb500'
|
42
|
+
end
|
37
43
|
end
|
38
44
|
|
39
|
-
|
40
|
-
|
45
|
+
describe 'school admin events' do
|
46
|
+
it 'creates a clever object for the object the event is about' do
|
47
|
+
@event = Clever::Event.construct_from(
|
48
|
+
type: 'schooladmins.created',
|
49
|
+
data: {
|
50
|
+
object: { id: '512bb9f2ca5e6fa77506133f' }
|
51
|
+
},
|
52
|
+
id: '512bb9f2ca5e6fa775061340'
|
53
|
+
)
|
54
|
+
@event.object.must_be_instance_of Clever::SchoolAdmin
|
55
|
+
end
|
41
56
|
end
|
42
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clever-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clever Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|