stormpath-sdk 1.0.0.beta.5 → 1.0.0.beta.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,6 +8,7 @@ describe Stormpath::DataStore do
8
8
  let(:application_cache) { data_store.cache_manager.get_cache 'applications' }
9
9
  let(:tenant_cache) { data_store.cache_manager.get_cache 'tenants' }
10
10
  let(:group_cache) { data_store.cache_manager.get_cache 'groups' }
11
+ let(:default_base_url) { Stormpath::DataStore::DEFAULT_BASE_URL }
11
12
 
12
13
  after do
13
14
  application_cache.clear
@@ -15,16 +16,31 @@ describe Stormpath::DataStore do
15
16
 
16
17
  describe '.region_for' do
17
18
  it 'pulls resource name from href' do
18
- region = data_store.send :region_for, 'https://api.stormpath.com/v1/directories/4NykYrYH0OBiOOVOg8LXQ5'
19
+ region = data_store.send :region_for, default_base_url+"/directories/4NykYrYH0OBiOOVOg8LXQ5"
19
20
  expect(region).to eq('directories')
20
21
  end
21
22
 
22
23
  it 'pulls resource name from href if its custom data also' do
23
- region = data_store.send :region_for, 'https://api.stormpath.com/v1/accounts/7jWpcEVSgawKkAZp8XDIEw/customData'
24
+ region = data_store.send :region_for, default_base_url+"/v1/accounts/7jWpcEVSgawKkAZp8XDIEw/customData"
24
25
  expect(region).to eq('customData')
25
26
  end
26
27
  end
27
28
 
29
+ describe 'custom data regex matchers' do
30
+ let(:custom_data_delete_field_url_regex) { data_store.send :custom_data_delete_field_url_regex }
31
+ context 'CUSTOM_DATA_DELETE_FIELD_REGEX' do
32
+ it 'should match custom data field href' do
33
+ expect(default_base_url+"/accounts/2f8U7r5JweVf1ZTtcJ08L8/customData/rank").to match(custom_data_delete_field_url_regex)
34
+ expect(default_base_url+"/groups/4x6vwucf1w9wjHvt7paGoY/customData/rank").to match(custom_data_delete_field_url_regex)
35
+ end
36
+
37
+ it 'should not match custom data resource href' do
38
+ expect(default_base_url+"/accounts/2f8U7r5JweVf1ZTtcJ08L8/customData").not_to match(custom_data_delete_field_url_regex)
39
+ expect(default_base_url+"/groups/4x6vwucf1w9wjHvt7paGoY/customData").not_to match(custom_data_delete_field_url_regex)
40
+ end
41
+ end
42
+ end
43
+
28
44
  describe '#delete' do
29
45
  before do
30
46
  resource = factory.resource 'application', 1, %w(tenant groups)
@@ -34,7 +34,7 @@ describe Stormpath::Resource::Account, :vcr do
34
34
  its(:tenant) { should be_instance_of Stormpath::Resource::Tenant }
35
35
  its(:directory) { should be_instance_of Stormpath::Resource::Directory }
36
36
  its(:custom_data) { should be_instance_of Stormpath::Resource::CustomData }
37
- its(:email_verification_token) { should be_instance_of Stormpath::Resource::EmailVerificationToken }
37
+ its(:email_verification_token) { should be_nil }
38
38
 
39
39
  its(:groups) { should be_instance_of Stormpath::Resource::Collection }
40
40
  its(:group_memberships) { should be_instance_of Stormpath::Resource::Collection }
@@ -2,13 +2,13 @@ require 'spec_helper'
2
2
 
3
3
  describe Stormpath::Resource::AccountStoreMapping, :vcr do
4
4
 
5
- def create_account_store_mapping(application, account_store, is_default_group_store=false)
5
+ def create_account_store_mapping(application, account_store, options={})
6
6
  test_api_client.account_store_mappings.create({
7
7
  application: application,
8
8
  account_store: account_store,
9
- list_index: 0,
10
- is_default_account_store: true,
11
- is_default_group_store: is_default_group_store
9
+ list_index: options[:list_index] || 0,
10
+ is_default_account_store: options[:is_default_account_store] || false,
11
+ is_default_group_store: options[:is_default_group_store] || false
12
12
  })
13
13
  end
14
14
 
@@ -22,7 +22,7 @@ describe Stormpath::Resource::AccountStoreMapping, :vcr do
22
22
  end
23
23
 
24
24
  describe "instances" do
25
- subject(:account_store_mapping) {create_account_store_mapping(application,directory)}
25
+ subject(:account_store_mapping) {create_account_store_mapping(application,directory, is_default_account_store: true)}
26
26
 
27
27
  [:list_index, :is_default_account_store, :is_default_group_store, :default_account_store, :default_group_store ].each do |prop_accessor|
28
28
  it { should respond_to prop_accessor }
@@ -48,15 +48,71 @@ describe Stormpath::Resource::AccountStoreMapping, :vcr do
48
48
 
49
49
 
50
50
  describe 'given an application' do
51
- let!(:account_store_mapping) {create_account_store_mapping(application,directory,true)}
52
51
  let(:reloaded_application) { test_api_client.applications.get application.href}
53
- it 'should retrive a default account store mapping' do
52
+
53
+ context 'on application creation' do
54
+ it 'there should be no default account/group store' do
55
+ expect(application.default_account_store_mapping).to eq(nil)
56
+ expect(application.default_group_store_mapping).to eq(nil)
57
+ end
58
+ end
59
+
60
+ it 'should retrive a default account store mapping one is created' do
61
+ account_store_mapping = create_account_store_mapping(application,directory, is_default_account_store: true, is_default_group_store: true)
62
+ expect(reloaded_application.default_account_store_mapping).to eq(account_store_mapping)
63
+ end
64
+
65
+ it 'should retrive a default group store mapping when one is created' do
66
+ account_store_mapping = create_account_store_mapping(application,directory, is_default_account_store: true, is_default_group_store: true)
67
+ expect(reloaded_application.default_group_store_mapping).to eq(account_store_mapping)
68
+ end
69
+
70
+ it 'change the default account store mapping, the application needs to be reloaded' do
71
+ account_store_mapping = create_account_store_mapping(application,directory, is_default_account_store: true)
72
+ expect(application.default_account_store_mapping).to eq(nil)
54
73
  expect(reloaded_application.default_account_store_mapping).to eq(account_store_mapping)
55
74
  end
56
75
 
57
- it 'should retrive a default group store mapping' do
76
+ it 'change the default group store mapping, the application needs to be reloaded' do
77
+ account_store_mapping = create_account_store_mapping(application,directory, is_default_account_store: true, is_default_group_store: true)
78
+ expect(application.default_group_store_mapping).to eq(nil)
58
79
  expect(reloaded_application.default_group_store_mapping).to eq(account_store_mapping)
59
80
  end
81
+
82
+ context 'remove the added default account/group store mapping' do
83
+ let(:re_reloaded_application) { test_api_client.applications.get application.href}
84
+
85
+ it 'there should not be a default account store mapping in the beginning and the end' do
86
+ expect(application.default_account_store_mapping).to eq(nil)
87
+ account_store_mapping = create_account_store_mapping(application,directory, is_default_account_store: true)
88
+
89
+ expect(application.default_account_store_mapping).to eq(nil)
90
+ expect(reloaded_application.default_account_store_mapping).to eq(account_store_mapping)
91
+
92
+ account_store_mapping.is_default_account_store = false
93
+ account_store_mapping.save
94
+
95
+ expect(application.default_account_store_mapping).to eq(nil)
96
+ expect(reloaded_application.default_account_store_mapping).to eq(account_store_mapping)
97
+ expect(re_reloaded_application.default_account_store_mapping).to eq(nil)
98
+ end
99
+
100
+ it 'there should not be a default group store mapping in the beginning and the end' do
101
+ expect(application.default_account_store_mapping).to eq(nil)
102
+ account_store_mapping = create_account_store_mapping(application,directory, is_default_group_store: true)
103
+
104
+ expect(application.default_group_store_mapping).to eq(nil)
105
+ expect(reloaded_application.default_group_store_mapping).to eq(account_store_mapping)
106
+
107
+ account_store_mapping.is_default_group_store = false
108
+ account_store_mapping.save
109
+
110
+ expect(application.default_group_store_mapping).to eq(nil)
111
+ expect(reloaded_application.default_group_store_mapping).to eq(account_store_mapping)
112
+ expect(re_reloaded_application.default_group_store_mapping).to eq(nil)
113
+ end
114
+ end
115
+
60
116
  end
61
117
 
62
118
  describe "given a directory" do
@@ -69,17 +125,32 @@ describe Stormpath::Resource::AccountStoreMapping, :vcr do
69
125
 
70
126
  describe "given a group" do
71
127
  let(:group) { directory.groups.create name: 'testGroup', description: 'testGroup for AccountStoreMappings' }
128
+ let(:reloaded_application) { test_api_client.applications.get application.href }
72
129
 
73
- before { create_account_store_mapping(application, group) }
74
- after { group.delete if group }
130
+ after do
131
+ group.delete if group
132
+ end
133
+
134
+ context 'add an account store mapping' do
135
+ it 'being a default account store' do
136
+ account_store_mapping = create_account_store_mapping(application, group, is_default_account_store: true)
137
+ expect(application.default_account_store_mapping).to eq(nil)
138
+ expect(application.account_store_mappings.count).to eq(1)
139
+ expect(reloaded_application.default_account_store_mapping).to eq(account_store_mapping)
140
+ end
141
+
142
+ it 'being a default group store, should raise an error' do
143
+ expect do
144
+ create_account_store_mapping(application, group, is_default_group_store: true)
145
+ end.to raise_error Stormpath::Error
146
+ end
75
147
 
76
- it 'add an account store mapping' do
77
- expect(application.account_store_mappings.count).to eq(1)
78
148
  end
149
+
79
150
  end
80
151
 
81
152
  describe "update attribute default_group_store" do
82
- let(:account_store_mapping) { create_account_store_mapping(application, directory) }
153
+ let(:account_store_mapping) { create_account_store_mapping(application, directory, is_default_account_store: true) }
83
154
  let(:reloaded_mapping){ application.account_store_mappings.get account_store_mapping.href }
84
155
 
85
156
  it 'should go from true to false' do
@@ -92,7 +163,7 @@ describe Stormpath::Resource::AccountStoreMapping, :vcr do
92
163
  end
93
164
 
94
165
  describe "given a mapping" do
95
- let!(:account_store_mapping) { create_account_store_mapping(application, directory) }
166
+ let!(:account_store_mapping) { create_account_store_mapping(application, directory, is_default_account_store: true) }
96
167
  let(:reloaded_application) { test_api_client.applications.get application.href}
97
168
 
98
169
  it 'function delete should destroy it' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Stormpath::Resource::Collection do
3
+ describe Stormpath::Resource::Collection, :vcr do
4
4
  let(:href) do
5
5
  'http://example.com'
6
6
  end
@@ -166,4 +166,204 @@ describe Stormpath::Resource::Collection do
166
166
  end
167
167
  end
168
168
  end
169
+
170
+ context 'live examples' do
171
+ context 'testing limits and offsets' do
172
+ let(:directory) {test_api_client.directories.create name: "Directory for pagination testing"}
173
+
174
+ let(:groups) do
175
+ ('A'..'Z').map do |letter|
176
+ directory.groups.create name: "#{letter}. pagination testing group "
177
+ end
178
+ end
179
+
180
+ after do
181
+ directory.delete
182
+ end
183
+
184
+ it 'should respond as expected with or without limits' do
185
+ expect(groups).to have(26).items
186
+
187
+ expect(directory.groups.limit(3)).to have(26).items
188
+
189
+ expect(directory.groups.offset(10).limit(3)).to have(16).items
190
+
191
+ expect(directory.groups.limit(3).offset(10)).to have(16).items
192
+
193
+ expect(directory.groups).to have(26).items
194
+
195
+ expect(directory.groups.limit(25)).to have(26).items
196
+
197
+ expect(directory.groups.limit(26)).to have(26).items
198
+
199
+ expect(directory.groups.limit(100)).to have(26).items
200
+
201
+ expect(directory.groups.limit(25)).to include(groups.last)
202
+
203
+ expect(directory.groups.offset(1).limit(25)).to include(groups.last)
204
+
205
+ expect(directory.groups.offset(1).limit(25)).not_to include(groups.first)
206
+
207
+ expect(directory.groups.offset(25)).to have(1).items
208
+
209
+ expect(directory.groups.offset(26)).to have(0).items
210
+ end
211
+ end
212
+
213
+ context 'testing limits and offsets with name checking' do
214
+ let(:directory) {test_api_client.directories.create name: "Directory for pagination testing"}
215
+
216
+ let!(:groups) do
217
+ ('1'..'100').map do |number|
218
+ directory.groups.create name: number
219
+ end
220
+ end
221
+
222
+ after do
223
+ directory.delete
224
+ end
225
+
226
+ it 'should paginate properly' do
227
+ expect(directory.groups).to have(100).items
228
+
229
+ expect(directory.groups.map {|group| group.name }).to eq(('1'..'100').to_a.sort)
230
+
231
+ expect(directory.groups.limit(30)).to have(100).items
232
+
233
+ expect(directory.groups.limit(30).current_page.items).to have(30).items
234
+
235
+ expect(directory.groups.limit(30).offset(30)).to have(70).items
236
+
237
+ expect(directory.groups.limit(30).offset(30).current_page.items).to have(30).items
238
+
239
+ expect(directory.groups.limit(30).offset(60)).to have(40).items
240
+
241
+ expect(directory.groups.limit(30).offset(60).current_page.items).to have(30).items
242
+
243
+ expect(directory.groups.limit(30).offset(90)).to have(10).items
244
+
245
+ expect(directory.groups.limit(30).offset(90).current_page.items).to have(10).items
246
+
247
+ expect(directory.groups.limit(30).map {|group| group.name }).to eq(('1'..'100').to_a.sort)
248
+
249
+ expect(directory.groups.limit(30).current_page.items.map {|group| group.name }).to eq(('1'..'100').to_a.sort.first(30))
250
+
251
+ expect(directory.groups.limit(30).offset(30).map {|group| group.name }).to eq(('1'..'100').to_a.sort.drop(30))
252
+
253
+ expect(directory.groups.limit(30).offset(30).current_page.items.map {|group| group.name }).to eq(('1'..'100').to_a.sort.drop(30).first(30))
254
+
255
+ expect(directory.groups.limit(30).offset(60).map {|group| group.name }).to eq(('1'..'100').to_a.sort.drop(60))
256
+
257
+ expect(directory.groups.limit(30).offset(60).current_page.items.map {|group| group.name }).to eq(('1'..'100').to_a.sort.drop(60).first(30))
258
+
259
+ expect(directory.groups.limit(30).offset(90).map {|group| group.name }).to eq(('1'..'100').to_a.sort.drop(90))
260
+
261
+ expect(directory.groups.limit(30).offset(90).current_page.items.map {|group| group.name }).to eq(('1'..'100').to_a.sort.drop(90).first(30))
262
+
263
+ expect(directory.groups.limit(30).offset(90).current_page.items.map {|group| group.name }).to eq(('1'..'100').to_a.sort.drop(90).first(10))
264
+
265
+ group_count = 0
266
+ directory.groups.each do |group|
267
+ group_count += 1
268
+ expect(('1'..'100').to_a).to include(group.name)
269
+ end
270
+
271
+ expect(group_count).to eq(100)
272
+ end
273
+ end
274
+
275
+ context '#wild characters search' do
276
+ let(:directory) {test_api_client.directories.create name: "Test directory"}
277
+
278
+ # !@#$%^&*()_-+=?><:]}[{'
279
+ # 'jlpicard/!@$%^*()_-+&=?><:]}[{'
280
+ let(:username) { 'jlpicard/!@$%^ *()_-+=?><:]}[{' }
281
+
282
+ let!(:account) do
283
+ directory.accounts.create username: username,
284
+ email: "capt@enterprise.com",
285
+ givenName: "Jean-Luc",
286
+ surname: "Picard",
287
+ password: "hakunaMatata179Enterprise"
288
+ end
289
+
290
+ after do
291
+ directory.delete
292
+ end
293
+
294
+ it 'should search accounts by username' do
295
+ expect(directory.accounts.search(username: username)).to have(1).items
296
+ end
297
+
298
+ it 'should search accounts by any column (aiming at username)' do
299
+ expect(directory.accounts.search(username)).to have(1).items
300
+ end
301
+
302
+ it 'should search accounts by email' do
303
+ expect(directory.accounts.search(email: "capt@enterprise.com")).to have(1).items
304
+ end
305
+
306
+ it 'should search accounts by any column (aiming at email)' do
307
+ expect(directory.accounts.search("capt@enterprise.com")).to have(1).items
308
+ end
309
+ end
310
+
311
+ context '#asterisk search on one attribute' do
312
+ let(:directory) {test_api_client.directories.create name: "Test directory"}
313
+
314
+ let!(:account) do
315
+ directory.accounts.create username: "jlpicard",
316
+ email: "capt@enterprise.com",
317
+ givenName: "Jean-Luc",
318
+ surname: "Picard",
319
+ password: "hakunaMatata179Enterprise"
320
+ end
321
+
322
+ after do
323
+ directory.delete
324
+ end
325
+
326
+ it 'should search accounts by username with asterisk at the beginning' do
327
+ expect(directory.accounts.search(username: "*card")).to have(1).items
328
+ end
329
+
330
+ it 'should search accounts by username with asterisk at the end' do
331
+ expect(directory.accounts.search(username: "jl*")).to have(1).items
332
+ end
333
+
334
+ it 'should search accounts by username with asterisk at the beginning and the end' do
335
+ expect(directory.accounts.search(username: "*pic*")).to have(1).items
336
+ end
337
+ end
338
+
339
+ context '#asterisk search on multiple attribute' do
340
+ let(:directory) {test_api_client.directories.create name: "Test directory"}
341
+
342
+ let!(:account) do
343
+ directory.accounts.create username: "jlpicard",
344
+ email: "capt@enterprise.com",
345
+ givenName: "Jean-Luc",
346
+ surname: "Picard",
347
+ password: "hakunaMatata179Enterprise"
348
+ end
349
+
350
+ after do
351
+ directory.delete
352
+ end
353
+
354
+ it 'should search accounts by username with asterisk at the beginning' do
355
+ expect(directory.accounts.search(username: "*card", email: "*enterprise.com")).to have(1).items
356
+ end
357
+
358
+ it 'should search accounts by username with asterisk at the end' do
359
+ expect(directory.accounts.search(username: "jl*", email: "capt*")).to have(1).items
360
+ end
361
+
362
+ it 'should search accounts by username with asterisk at the beginning and the end' do
363
+ expect(directory.accounts.search(username: "*pic*", email: "*enterprise*")).to have(1).items
364
+ end
365
+ end
366
+
367
+ end
368
+
169
369
  end
@@ -1,198 +1,25 @@
1
- # test_api_client.accounts.get "https://api.stormpath.com/v1/accounts/1SmmWv659tY9Eeb4qKZqr0"
2
1
  require 'spec_helper'
3
2
 
4
3
  describe Stormpath::Resource::CustomData, :vcr do
5
-
6
- RESERVED_FIELDS = %w( created_at modified_at meta sp_meta spmeta ion_meta ionmeta )
7
-
8
- describe "#for accounts" do
9
- let(:directory) { test_api_client.directories.create name: 'test_directory' }
10
-
11
- let(:account) do
12
- directory.accounts.create username: "jlpicard",
13
- email: "capt@enterprise.com",
14
- givenName: "Jean-Luc",
15
- surname: "Picard",
16
- password: "uGhd%a8Kl!"
17
- end
18
-
19
- let(:reloaded_account) { test_api_client.accounts.get account.href }
20
-
21
- after do
22
- account.delete if account
23
- directory.delete if directory
24
- end
25
-
26
- it 'read reserved data' do
27
- expect(account.custom_data["href"]).not_to eq(nil)
28
- expect(account.custom_data["created_at"]).not_to eq(nil)
29
- expect(account.custom_data["modified_at"]).not_to eq(nil)
30
- end
31
-
32
- RESERVED_FIELDS.each do |reserved_field|
33
- it "set reserved data #{reserved_field} should raise error" do
34
- account.custom_data[reserved_field] = 12
35
- expect{ account.custom_data.save }.to raise_error
36
- end
37
- end
38
-
39
- it 'set custom data' do
40
- account.custom_data[:rank] = "Captain"
41
- expect(account.custom_data[:rank]).to eq("Captain")
42
- account.custom_data.save
43
- expect(reloaded_account.custom_data[:rank]).to eq("Captain")
44
- end
45
-
46
- it 'set nested custom data' do
47
- account.custom_data[:special_rank] = "Captain"
48
- account.custom_data[:permissions] = {"crew_quarters" => "93-601"}
49
- expect(account.custom_data[:permissions]).to eq({"crew_quarters" => "93-601"})
50
- account.custom_data.save
51
- expect(reloaded_account.custom_data[:special_rank]).to eq("Captain")
52
- expect(reloaded_account.custom_data[:permissions]).to eq({"crew_quarters" => "93-601"})
53
- end
54
-
55
- it 'not raise errors when saving a empty properties array' do
56
- account.custom_data.save
57
- end
58
-
59
- it 'trigger custom data saving on account.save' do
60
- account.custom_data[:rank] = "Captain"
61
- account.surname = "Picard!"
62
- account.save
63
- expect(reloaded_account.surname).to eq("Picard!")
64
- expect(reloaded_account.custom_data[:rank]).to eq("Captain")
65
- end
66
-
67
- it 'delete all custom data' do
68
- account.custom_data[:rank] = "Captain"
69
- account.custom_data.save
70
- expect(account.custom_data[:rank]).to eq("Captain")
71
- account.custom_data.delete
72
- expect(reloaded_account.custom_data[:rank]).to eq(nil)
73
- end
74
-
75
- it 'delete a specific custom data field' do
76
- account.custom_data[:rank] = "Captain"
77
- account.custom_data["favorite_drink"] = "Earl Grey Tea"
78
- account.custom_data.save
79
-
80
- account.custom_data.delete(:rank)
81
- account.custom_data.save
82
-
83
- expect(reloaded_account.custom_data[:rank]).to eq(nil)
84
- expect(reloaded_account.custom_data["favorite_drink"]).to eq("Earl Grey Tea")
85
- end
86
-
87
- context 'should respond to' do
88
- it '#has_key?' do
89
- expect(account.custom_data.has_key? "created_at").to be_true
90
- end
91
-
92
- it '#include?' do
93
- expect(account.custom_data.include? "created_at").to be_true
94
- end
95
-
96
- it '#has_value?' do
97
- account.custom_data[:rank] = "Captain"
98
- account.custom_data.save
99
- expect(reloaded_account.custom_data.has_value? "Captain").to be_true
100
- end
101
-
102
- it '#store' do
103
- account.custom_data.store(:rank, "Captain")
104
- account.custom_data.save
105
- expect(reloaded_account.custom_data[:rank]).to eq("Captain")
106
- end
107
-
108
- it '#keys' do
109
- expect(account.custom_data.keys).to be_kind_of(Array)
110
- expect(account.custom_data.keys).to have_at_least(3).items
111
- expect(account.custom_data.keys.map {|key| key.to_s.camelize :lower}).to eq(account.custom_data.properties.keys)
112
- end
113
-
114
- it '#values' do
115
- account.custom_data[:permissions] = {"crew_quarters" => "93-601"}
116
- account.custom_data.save
117
- expect(reloaded_account.custom_data.values).to include({"crew_quarters" => "93-601"})
118
- expect(reloaded_account.custom_data.values).to eq(reloaded_account.custom_data.properties.values)
119
- end
120
- end
121
-
4
+ after do
5
+ directory.delete if directory
122
6
  end
123
7
 
124
- describe "#for groups" do
8
+ context 'wuth caching regions' do
125
9
  let(:directory) { test_api_client.directories.create name: 'test_directory' }
126
10
 
127
- let(:group) { directory.groups.create name: 'test_group' }
128
-
129
- let(:reloaded_group) { test_api_client.groups.get group.href }
130
-
131
- after do
132
- group.delete if group
133
- directory.delete if directory
134
- end
135
-
136
- it 'read reserved data' do
137
- expect(group.custom_data["href"]).not_to eq(nil)
138
- expect(group.custom_data["created_at"]).not_to eq(nil)
139
- expect(group.custom_data["modified_at"]).not_to eq(nil)
140
- end
141
-
142
- RESERVED_FIELDS.each do |reserved_field|
143
- it "set reserved data #{reserved_field} should raise error" do
144
- group.custom_data[reserved_field] = 12
145
- expect{ group.custom_data.save }.to raise_error
146
- end
147
- end
148
-
149
- it 'set custom data' do
150
- group.custom_data[:series] = "Enterprise"
151
- expect(group.custom_data[:series]).to eq("Enterprise")
152
- group.custom_data.save
153
- expect(reloaded_group.custom_data[:series]).to eq("Enterprise")
154
- end
155
-
156
- it 'set nested custom data' do
157
- group.custom_data[:special_rank] = "Captain"
158
- group.custom_data[:permissions] = {"crew_quarters" => "93-601"}
159
- expect(group.custom_data[:permissions]).to eq({"crew_quarters" => "93-601"})
160
- group.custom_data.save
161
- expect(reloaded_group.custom_data[:special_rank]).to eq("Captain")
162
- expect(reloaded_group.custom_data[:permissions]).to eq({"crew_quarters" => "93-601"})
163
- end
164
-
165
- it 'not raise errors when saving a empty properties array' do
166
- group.custom_data.save
167
- end
168
-
169
- it 'trigger custom data saving on group.save' do
170
- group.custom_data[:series] = "Enterprise"
171
- group.description = "founded on the twin principles of joy and service"
172
- group.save
173
- expect(reloaded_group.description).to eq("founded on the twin principles of joy and service")
174
- expect(reloaded_group.custom_data[:series]).to eq("Enterprise")
175
- end
11
+ it_behaves_like 'account_custom_data'
12
+ it_behaves_like 'group_custom_data'
13
+ end
176
14
 
177
- it 'delete all custom data' do
178
- group.custom_data["series"] = "Enterprise"
179
- group.custom_data.save
180
- expect(group.custom_data["series"]).to eq("Enterprise")
181
- group.custom_data.delete
182
- expect(reloaded_group.custom_data["series"]).to eq(nil)
15
+ context 'without caching regions' do
16
+ let(:disabled_cache_client) do
17
+ @disabled_cache_client ||= Stormpath::Client.new({api_key: test_api_key, cache: { store: Stormpath::Cache::DisabledCacheStore }})
183
18
  end
184
19
 
185
- it 'delete a specific custom data field' do
186
- group.custom_data["series"] = "Enterprise"
187
- group.custom_data["favorite_drink"] = "Earl Grey Tea"
188
- group.custom_data.save
189
-
190
- group.custom_data.delete("series")
191
- group.custom_data.save
20
+ let(:directory) { disabled_cache_client.directories.create name: 'test_directory' }
192
21
 
193
- expect(reloaded_group.custom_data["series"]).to eq(nil)
194
- expect(reloaded_group.custom_data["favorite_drink"]).to eq("Earl Grey Tea")
195
- end
22
+ it_behaves_like 'account_custom_data'
23
+ it_behaves_like 'group_custom_data'
196
24
  end
197
-
198
25
  end