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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3fbf4a2b0e378bcb5b8b6ddf915b9a893637d817
4
- data.tar.gz: d4e7d196ec9472367e3055c7af19ac76de4150fd
3
+ metadata.gz: 3248341c0c2b2897a297a4b47d4254f1521c5247
4
+ data.tar.gz: cc02fa1d0c39afb6f63af754eed6e131143a3234
5
5
  SHA512:
6
- metadata.gz: 74b6cb015615bb153bc3b04b9d6c9d6a1a0eff230af5becb19d566996cb5c45c6bf69f9015eb36b9d1ab14a502fabd409a0ab7a9a65f54a565a510bbd839e747
7
- data.tar.gz: 4bb8fba062d4766b7f6e770965ffa221c9ee321f1f260f47de38fa360b6218e4d38d592519bfd5727013602eafedf13833b7149203a222e8015ff9606aa0915a
6
+ metadata.gz: 7a733af1ed14ff21d62c6bb8c6b4700a5f4c3a8c6d600cbab487a3b6fba9ed149415a0c7946860aded98e11bc51dcf5ea2775f5e47251f14d7d3a6a7f4c5c630
7
+ data.tar.gz: 1725a84c6ceb827d63eb66605fd9f1ce00f605ae121535c2c84c661af8cc0d5e866c91f8d4ac503ccc09cf7ee522896614981f85d8fed750e034fd4d81557d09
@@ -1,3 +1,7 @@
1
+ ## 0.13.1 (2015-10-19)
2
+
3
+ * Fix bug where school_admins used incorrect event type
4
+
1
5
  ## 0.13.0 (2015-10-05)
2
6
 
3
7
  * Add support for school admins
@@ -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
@@ -4,6 +4,8 @@ module Clever
4
4
  include Clever::APIOperations::List
5
5
  @uri = 'school_admins'
6
6
  @plural = 'school_admins'
7
+ @event_name = 'schooladmins'
8
+
7
9
  @linked_resources = [:schools]
8
10
 
9
11
  # Optional attributes
@@ -2,5 +2,5 @@
2
2
  module Clever
3
3
  # Version. Follows semantic versioning, as described here:
4
4
  # http://semver.org/
5
- VERSION = '0.13.0'
5
+ VERSION = '0.13.1'
6
6
  end
@@ -2,41 +2,56 @@ require 'test_helper'
2
2
 
3
3
  # test events resource
4
4
  describe Clever::Event do
5
- before do
6
- @event = Clever::Event.construct_from(
7
- type: 'sections.created',
8
- data: {
9
- object: { id: '512bb9f2ca5e6fa77506133f' }
10
- },
11
- id: '512bb9f2ca5e6fa775061340'
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
- @updated_event = Clever::Event.construct_from(
15
- type: 'sections.updated',
16
- data: {
17
- object: { id: '510980c2923bcbba1f0ce5dd' },
18
- previous_attributes: {
19
- teacher: '510980a6923bcbba1f0cb500',
20
- last_modified: '2013-03-11T15:38:58.558Z'
21
- }
22
- },
23
- id: '514767bf80833fb55b1c2dd7'
24
- )
25
- end
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
- it 'creates a clever object for the object the event is about' do
28
- @event.object.must_be_instance_of Clever::Section
29
- end
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
- it 'knows what action the event is about (created/updated/deleted)' do
32
- @event.action.must_equal 'created'
33
- end
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
- it "returns an empty hash if there aren't previous attributes" do
36
- @event.previous_attributes.must_equal {}
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
- it "has an event's previous attributes" do
40
- @updated_event.previous_attributes[:teacher].must_equal '510980a6923bcbba1f0cb500'
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.0
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-05 00:00:00.000000000 Z
11
+ date: 2015-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json