ruby-trello-czuger 2.0.0
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 +7 -0
- data/README.md +182 -0
- data/lib/trello.rb +163 -0
- data/lib/trello/action.rb +68 -0
- data/lib/trello/association.rb +14 -0
- data/lib/trello/association_proxy.rb +42 -0
- data/lib/trello/attachment.rb +40 -0
- data/lib/trello/authorization.rb +187 -0
- data/lib/trello/basic_data.rb +132 -0
- data/lib/trello/board.rb +211 -0
- data/lib/trello/card.rb +467 -0
- data/lib/trello/checklist.rb +143 -0
- data/lib/trello/client.rb +120 -0
- data/lib/trello/comment.rb +62 -0
- data/lib/trello/configuration.rb +68 -0
- data/lib/trello/core_ext/array.rb +6 -0
- data/lib/trello/core_ext/hash.rb +6 -0
- data/lib/trello/core_ext/string.rb +6 -0
- data/lib/trello/cover_image.rb +8 -0
- data/lib/trello/has_actions.rb +9 -0
- data/lib/trello/item.rb +37 -0
- data/lib/trello/item_state.rb +30 -0
- data/lib/trello/json_utils.rb +64 -0
- data/lib/trello/label.rb +108 -0
- data/lib/trello/label_name.rb +31 -0
- data/lib/trello/list.rb +114 -0
- data/lib/trello/member.rb +112 -0
- data/lib/trello/multi_association.rb +12 -0
- data/lib/trello/net.rb +39 -0
- data/lib/trello/notification.rb +61 -0
- data/lib/trello/organization.rb +68 -0
- data/lib/trello/plugin_datum.rb +34 -0
- data/lib/trello/token.rb +37 -0
- data/lib/trello/webhook.rb +103 -0
- data/spec/action_spec.rb +149 -0
- data/spec/array_spec.rb +13 -0
- data/spec/association_spec.rb +26 -0
- data/spec/basic_auth_policy_spec.rb +51 -0
- data/spec/board_spec.rb +442 -0
- data/spec/card_spec.rb +822 -0
- data/spec/checklist_spec.rb +296 -0
- data/spec/client_spec.rb +257 -0
- data/spec/configuration_spec.rb +95 -0
- data/spec/hash_spec.rb +15 -0
- data/spec/integration/how_to_authorize_spec.rb +53 -0
- data/spec/integration/how_to_use_boards_spec.rb +48 -0
- data/spec/integration/integration_test.rb +40 -0
- data/spec/item_spec.rb +75 -0
- data/spec/json_utils_spec.rb +73 -0
- data/spec/label_spec.rb +205 -0
- data/spec/list_spec.rb +253 -0
- data/spec/member_spec.rb +159 -0
- data/spec/notification_spec.rb +143 -0
- data/spec/oauth_policy_spec.rb +160 -0
- data/spec/organization_spec.rb +71 -0
- data/spec/spec_helper.rb +435 -0
- data/spec/string_spec.rb +55 -0
- data/spec/token_spec.rb +89 -0
- data/spec/trello_spec.rb +134 -0
- data/spec/webhook_spec.rb +130 -0
- metadata +200 -0
data/spec/list_spec.rb
ADDED
@@ -0,0 +1,253 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Trello
|
4
|
+
describe List do
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
let(:list) { client.find(:list, 'abcdef123456789123456789') }
|
8
|
+
let(:client) { Client.new }
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
allow(client)
|
12
|
+
.to receive(:get)
|
13
|
+
.with('/lists/abcdef123456789123456789', {})
|
14
|
+
.and_return JSON.generate(lists_details.first)
|
15
|
+
|
16
|
+
allow(client)
|
17
|
+
.to receive(:get)
|
18
|
+
.with('/boards/abcdef123456789123456789', {})
|
19
|
+
.and_return JSON.generate(boards_details.first)
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'finding' do
|
23
|
+
let(:client) { Trello.client }
|
24
|
+
|
25
|
+
it 'delegates to client#find' do
|
26
|
+
expect(client)
|
27
|
+
.to receive(:find)
|
28
|
+
.with(:list, 'abcdef123456789123456789', {})
|
29
|
+
|
30
|
+
List.find('abcdef123456789123456789')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'is equivalent to client#find' do
|
34
|
+
expect(List.find('abcdef123456789123456789')).to eq(list)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'creating' do
|
39
|
+
let(:client) { Trello.client }
|
40
|
+
|
41
|
+
it 'creates a new record' do
|
42
|
+
list = List.new(lists_details.first)
|
43
|
+
expect(list).to be_valid
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'must not be valid if not given a name' do
|
47
|
+
list = List.new(lists_details.first.except('name'))
|
48
|
+
expect(list).to_not be_valid
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'must not be valid if not given a list id' do
|
52
|
+
list = List.new(lists_details.first.except('id'))
|
53
|
+
expect(list).to_not be_valid
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'initializes all fields from response-like formatted hash' do
|
57
|
+
list_details = lists_details.first
|
58
|
+
list = List.new(list_details)
|
59
|
+
expect(list.id).to eq(list_details['id'])
|
60
|
+
expect(list.name).to eq(list_details['name'])
|
61
|
+
expect(list.closed).to eq(list_details['closed'])
|
62
|
+
expect(list.board_id).to eq(list_details['idBoard'])
|
63
|
+
expect(list.pos).to eq(list_details['pos'])
|
64
|
+
expect(list.source_list_id).to eq(list_details['idListSource'])
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'initializes required fields from options-like formatted hash' do
|
68
|
+
list_details = lists_details[1]
|
69
|
+
list = List.new(list_details)
|
70
|
+
expect(list.name).to eq list_details[:name]
|
71
|
+
expect(list.board_id).to eq list_details[:board_id]
|
72
|
+
expect(list.pos).to eq list_details[:pos]
|
73
|
+
expect(list.source_list_id).to eq list_details[:source_list_id]
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'creates a new record and saves it on Trello', refactor: true do
|
77
|
+
payload = {
|
78
|
+
name: 'Test List',
|
79
|
+
board_id: 'abcdef123456789123456789',
|
80
|
+
pos: 42,
|
81
|
+
source_list_id: 'abcdef123456789'
|
82
|
+
}
|
83
|
+
|
84
|
+
result = JSON.generate(payload)
|
85
|
+
|
86
|
+
expected_payload = {
|
87
|
+
name: 'Test List',
|
88
|
+
closed: false,
|
89
|
+
idBoard: 'abcdef123456789123456789',
|
90
|
+
pos: 42,
|
91
|
+
idListSource: 'abcdef123456789'
|
92
|
+
}
|
93
|
+
|
94
|
+
expect(client)
|
95
|
+
.to receive(:post)
|
96
|
+
.with('/lists', expected_payload).and_return result
|
97
|
+
|
98
|
+
list = List.create(payload)
|
99
|
+
expect(list).to be_a List
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'updating' do
|
104
|
+
it 'updating name does a put on the correct resource with the correct value' do
|
105
|
+
expected_new_name = 'xxx'
|
106
|
+
|
107
|
+
payload = {
|
108
|
+
name: expected_new_name,
|
109
|
+
closed: false,
|
110
|
+
pos: list.pos
|
111
|
+
}
|
112
|
+
|
113
|
+
expect(client)
|
114
|
+
.to receive(:put)
|
115
|
+
.once
|
116
|
+
.with('/lists/abcdef123456789123456789', payload)
|
117
|
+
|
118
|
+
list.name = expected_new_name
|
119
|
+
list.save
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'updates position' do
|
123
|
+
new_position = 42
|
124
|
+
payload = {
|
125
|
+
name: list.name,
|
126
|
+
closed: list.closed,
|
127
|
+
pos: new_position
|
128
|
+
}
|
129
|
+
|
130
|
+
expect(client)
|
131
|
+
.to receive(:put)
|
132
|
+
.once
|
133
|
+
.with('/lists/abcdef123456789123456789', payload)
|
134
|
+
|
135
|
+
list.pos = new_position
|
136
|
+
list.save
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'fields' do
|
141
|
+
it 'gets its id' do
|
142
|
+
expect(list.id).to eq lists_details.first['id']
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'gets its name' do
|
146
|
+
expect(list.name).to eq lists_details.first['name']
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'knows if it is open or closed' do
|
150
|
+
expect(list.closed).to eq lists_details.first['closed']
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'has a board' do
|
154
|
+
expect(list.board).to eq Board.new(boards_details.first)
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'gets its position' do
|
158
|
+
expect(list.pos).to eq lists_details.first['pos']
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'actions' do
|
163
|
+
it 'has a list of actions' do
|
164
|
+
allow(client)
|
165
|
+
.to receive(:get)
|
166
|
+
.with('/lists/abcdef123456789123456789/actions', { filter: :all })
|
167
|
+
.and_return actions_payload
|
168
|
+
|
169
|
+
expect(list.actions.count).to be > 0
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'cards' do
|
174
|
+
it 'has a list of cards' do
|
175
|
+
allow(client)
|
176
|
+
.to receive(:get)
|
177
|
+
.with('/lists/abcdef123456789123456789/cards', { filter: :open })
|
178
|
+
.and_return cards_payload
|
179
|
+
|
180
|
+
expect(list.cards.count).to be > 0
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'moves cards to another list' do
|
184
|
+
other_list = List.new(lists_details.first.merge(id: 'otherListID', cards: []))
|
185
|
+
|
186
|
+
allow(client)
|
187
|
+
.to receive(:post)
|
188
|
+
.with('/lists/abcdef123456789123456789/moveAllCards', { idBoard: other_list.board_id, idList: other_list.id })
|
189
|
+
.and_return cards_payload
|
190
|
+
|
191
|
+
expect(list.move_all_cards(other_list)).to eq cards_payload
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'archives all cards' do
|
195
|
+
allow(client)
|
196
|
+
.to receive(:post)
|
197
|
+
.with('/lists/abcdef123456789123456789/archiveAllCards')
|
198
|
+
.and_return cards_payload
|
199
|
+
|
200
|
+
expect(list.archive_all_cards).to eq cards_payload
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe '#closed?' do
|
205
|
+
it 'returns the closed attribute' do
|
206
|
+
expect(list).to_not be_closed
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe '#close' do
|
211
|
+
it 'updates the close attribute to true' do
|
212
|
+
list.close
|
213
|
+
expect(list).to be_closed
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
describe '#close!' do
|
218
|
+
it 'updates the close attribute to true and saves the list' do
|
219
|
+
expect(client)
|
220
|
+
.to receive(:put)
|
221
|
+
.once
|
222
|
+
.with('/lists/abcdef123456789123456789', {
|
223
|
+
name: list.name,
|
224
|
+
closed: true,
|
225
|
+
pos: list.pos
|
226
|
+
})
|
227
|
+
|
228
|
+
list.close!
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe "#update_fields" do
|
233
|
+
it "does not set any fields when the fields argument is empty" do
|
234
|
+
expected = {
|
235
|
+
'id' => 'id',
|
236
|
+
'name' => 'name',
|
237
|
+
'closed' => 'closed',
|
238
|
+
'idBoard' => 'board_id',
|
239
|
+
'pos' => 'pos',
|
240
|
+
'idListSource' => 'source_list_id'
|
241
|
+
}
|
242
|
+
|
243
|
+
label = List.new(expected)
|
244
|
+
|
245
|
+
label.update_fields({})
|
246
|
+
|
247
|
+
expected.each do |key, value|
|
248
|
+
expect(label.send(value)).to eq expected[key]
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
data/spec/member_spec.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# Specs covering the members namespace in the Trello API
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
module Trello
|
6
|
+
describe Member do
|
7
|
+
include Helpers
|
8
|
+
|
9
|
+
let(:member) { client.find(:member, 'abcdef123456789012345678') }
|
10
|
+
let(:client) { Client.new }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(client)
|
14
|
+
.to receive(:get)
|
15
|
+
.with('/members/abcdef123456789012345678', {})
|
16
|
+
.and_return user_payload
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'finding' do
|
20
|
+
let(:client) { Trello.client }
|
21
|
+
|
22
|
+
it 'delegates to Trello.client#find' do
|
23
|
+
expect(client)
|
24
|
+
.to receive(:find)
|
25
|
+
.with(:member, 'abcdef123456789012345678', {})
|
26
|
+
|
27
|
+
Member.find('abcdef123456789012345678')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'is equivalent to client#find' do
|
31
|
+
expect(Member.find('abcdef123456789012345678')).to eq(member)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'attributes' do
|
36
|
+
before do
|
37
|
+
allow(client)
|
38
|
+
.to receive(:get)
|
39
|
+
.with("/members/abcdef123456789012345678/#{resource}", { filter: filter })
|
40
|
+
.and_return payload
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'actions' do
|
44
|
+
let(:resource) { 'actions' }
|
45
|
+
let(:filter) { :all }
|
46
|
+
let(:payload) { actions_payload }
|
47
|
+
|
48
|
+
it 'retrieves a list of actions' do
|
49
|
+
expect(member.actions.count).to be > 0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe 'boards' do
|
54
|
+
let(:resource) { 'boards' }
|
55
|
+
let(:filter) { :all }
|
56
|
+
let(:payload) { boards_payload }
|
57
|
+
|
58
|
+
it { expect(member.boards.count).to be > 0 }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'cards' do
|
62
|
+
let(:resource) { 'cards' }
|
63
|
+
let(:filter) { :open }
|
64
|
+
let(:payload) { cards_payload }
|
65
|
+
|
66
|
+
it { expect(member.cards.count).to be > 0 }
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'organizations' do
|
70
|
+
let(:resource) { 'organizations' }
|
71
|
+
let(:filter) { :all }
|
72
|
+
let(:payload) { orgs_payload }
|
73
|
+
|
74
|
+
it { expect(member.organizations.count).to be > 0 }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'notifications' do
|
79
|
+
it 'has a list of notifications' do
|
80
|
+
allow(client)
|
81
|
+
.to receive(:get)
|
82
|
+
.with('/members/abcdef123456789012345678/notifications', {})
|
83
|
+
.and_return '[' << notification_payload << ']'
|
84
|
+
|
85
|
+
expect(member.notifications.count).to eq 1
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'personal' do
|
90
|
+
it 'gets the members bio' do
|
91
|
+
expect(member.bio).to eq user_details['bio']
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'gets the full name' do
|
95
|
+
expect(member.full_name).to eq user_details['fullName']
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'gets the avatar id' do
|
99
|
+
expect(member.avatar_id).to eq user_details['avatarHash']
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'returns a valid url for the avatar' do
|
103
|
+
expect(member.avatar_url(size: :large)).to eq 'https://trello-avatars.s3.amazonaws.com/abcdef1234567890abcdef1234567890/170.png'
|
104
|
+
expect(member.avatar_url(size: :small)).to eq 'https://trello-avatars.s3.amazonaws.com/abcdef1234567890abcdef1234567890/30.png'
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'gets the url' do
|
108
|
+
expect(member.url).to eq user_details['url']
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'gets the username' do
|
112
|
+
expect(member.username).to eq user_details['username']
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'gets the email' do
|
116
|
+
expect(member.email).to eq user_details['email']
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'gets the initials' do
|
120
|
+
expect(member.initials).to eq user_details['initials']
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'modification' do
|
125
|
+
it 'lets us know a field has changed without committing it' do
|
126
|
+
expect(member).to_not be_changed
|
127
|
+
member.bio = 'New and amazing'
|
128
|
+
expect(member).to be_changed
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'does not understand the #id= method' do
|
132
|
+
expect { member.id = '42' }.to raise_error NoMethodError
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "#update_fields" do
|
137
|
+
it "does not set any fields when the fields argument is empty" do
|
138
|
+
expected = {
|
139
|
+
'id' => 'id',
|
140
|
+
'fullName' => 'full_name',
|
141
|
+
'email' => 'email',
|
142
|
+
'username' => 'username',
|
143
|
+
'initials' => 'initials',
|
144
|
+
'avatarHash' => 'avatar_id',
|
145
|
+
'bio' => 'bio',
|
146
|
+
'url' => 'url'
|
147
|
+
}
|
148
|
+
|
149
|
+
member = Member.new(expected)
|
150
|
+
|
151
|
+
member.update_fields({})
|
152
|
+
|
153
|
+
expected.each do |key, value|
|
154
|
+
expect(member.send(value)).to eq expected[key]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Trello
|
4
|
+
describe Notification do
|
5
|
+
include Helpers
|
6
|
+
|
7
|
+
let(:notification) { member.notifications.first }
|
8
|
+
let(:member) { client.find(:member, "abcdef123456789012345678") }
|
9
|
+
let(:client) { Client.new }
|
10
|
+
|
11
|
+
before do
|
12
|
+
allow(client)
|
13
|
+
.to receive(:get)
|
14
|
+
.with("/members/abcdef123456789012345678", {})
|
15
|
+
.and_return user_payload
|
16
|
+
|
17
|
+
allow(client)
|
18
|
+
.to receive(:get)
|
19
|
+
.with("/members/abcdef123456789012345678/notifications", {})
|
20
|
+
.and_return("[" << notification_payload << "]")
|
21
|
+
end
|
22
|
+
|
23
|
+
context "finding" do
|
24
|
+
let(:client) { Trello.client }
|
25
|
+
|
26
|
+
it "can find a specific notification" do
|
27
|
+
allow(client)
|
28
|
+
.to receive(:get)
|
29
|
+
.with("/notifications/#{notification_details['id']}", {})
|
30
|
+
.and_return notification_payload
|
31
|
+
|
32
|
+
expect(Notification.find(notification_details['id'])).to eq notification
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "boards" do
|
37
|
+
it "can retrieve the board" do
|
38
|
+
allow(client)
|
39
|
+
.to receive(:get)
|
40
|
+
.with("/notifications/#{notification_details['id']}/board")
|
41
|
+
.and_return JSON.generate(boards_details.first)
|
42
|
+
|
43
|
+
expect(notification.board.id).to eq boards_details.first['id']
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "lists" do
|
48
|
+
it "can retrieve the list" do
|
49
|
+
allow(client)
|
50
|
+
.to receive(:get)
|
51
|
+
.with("/notifications/#{notification_details['id']}/list")
|
52
|
+
.and_return JSON.generate(lists_details.first)
|
53
|
+
|
54
|
+
expect(notification.list.id).to eq lists_details.first['id']
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "cards" do
|
59
|
+
it "can retrieve the card" do
|
60
|
+
allow(client)
|
61
|
+
.to receive(:get)
|
62
|
+
.with("/notifications/#{notification_details['id']}/card")
|
63
|
+
.and_return JSON.generate(cards_details.first)
|
64
|
+
|
65
|
+
expect(notification.card.id).to eq cards_details.first['id']
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "members" do
|
70
|
+
it "can retrieve the member" do
|
71
|
+
allow(client)
|
72
|
+
.to receive(:get)
|
73
|
+
.with("/notifications/#{notification_details['id']}/member")
|
74
|
+
.and_return user_payload
|
75
|
+
|
76
|
+
expect(notification.member.id).to eq user_details['id']
|
77
|
+
end
|
78
|
+
|
79
|
+
it "can retrieve the member creator" do
|
80
|
+
allow(client)
|
81
|
+
.to receive(:get)
|
82
|
+
.with("/members/#{user_details['id']}", {})
|
83
|
+
.and_return user_payload
|
84
|
+
|
85
|
+
expect(notification.member_creator.id).to eq user_details['id']
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "organization" do
|
90
|
+
it "can retrieve the organization" do
|
91
|
+
allow(client)
|
92
|
+
.to receive(:get)
|
93
|
+
.with("/notifications/#{notification_details['id']}/organization")
|
94
|
+
.and_return JSON.generate(orgs_details.first)
|
95
|
+
|
96
|
+
expect(notification.organization.id).to eq orgs_details.first['id']
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "local" do
|
101
|
+
it "gets the read status" do
|
102
|
+
expect(notification.unread?).to eq notification_details['unread']
|
103
|
+
end
|
104
|
+
|
105
|
+
it "gets the type" do
|
106
|
+
expect(notification.type).to eq notification_details['type']
|
107
|
+
end
|
108
|
+
|
109
|
+
it "gets the date" do
|
110
|
+
expect(notification.date).to eq notification_details['date']
|
111
|
+
end
|
112
|
+
|
113
|
+
it "gets the data" do
|
114
|
+
expect(notification.data).to eq notification_details['data']
|
115
|
+
end
|
116
|
+
|
117
|
+
it "gets the member creator id" do
|
118
|
+
expect(notification.member_creator_id).to eq notification_details['idMemberCreator']
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "#update_fields" do
|
123
|
+
it "does not set any fields when the fields argument is empty" do
|
124
|
+
expected = {
|
125
|
+
'id' => 'id',
|
126
|
+
'unread' => 'unread',
|
127
|
+
'type' => 'type',
|
128
|
+
'date' => 'date',
|
129
|
+
'data' => 'data',
|
130
|
+
'idMemberCreator' => 'member_creator_id'
|
131
|
+
}
|
132
|
+
|
133
|
+
notification = Notification.new(expected)
|
134
|
+
|
135
|
+
notification.update_fields({})
|
136
|
+
|
137
|
+
expected.each do |key, value|
|
138
|
+
expect(notification.send(value)).to eq expected[key]
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|