stormpath-sdk 1.3.0 → 1.3.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/.rspec +1 -0
- data/.travis.yml +0 -3
- data/CHANGES.md +9 -0
- data/README.md +8 -21
- data/Rakefile +1 -15
- data/lib/stormpath-sdk/oauth/error.rb +21 -0
- data/lib/stormpath-sdk/oauth/local_access_token_verification.rb +2 -2
- data/lib/stormpath-sdk/oauth/remote_access_token_verification.rb +2 -2
- data/lib/stormpath-sdk/version.rb +2 -2
- data/spec/auth/http_basic_authentication_spec.rb +6 -21
- data/spec/auth/http_bearer_authentication_spec.rb +11 -24
- data/spec/client_spec.rb +116 -258
- data/spec/oauth/access_token_authentication_result_spec.rb +14 -14
- data/spec/provider/provider_spec.rb +32 -40
- data/spec/resource/account_creation_policy_spec.rb +8 -13
- data/spec/resource/account_link_spec.rb +4 -17
- data/spec/resource/account_spec.rb +37 -81
- data/spec/resource/account_store_mapping_spec.rb +20 -32
- data/spec/resource/account_store_spec.rb +8 -31
- data/spec/resource/api_key_spec.rb +11 -14
- data/spec/resource/application_spec.rb +39 -168
- data/spec/resource/collection_spec.rb +17 -17
- data/spec/resource/custom_data_spec.rb +2 -2
- data/spec/resource/directory_spec.rb +164 -240
- data/spec/resource/email_template_spec.rb +21 -24
- data/spec/resource/group_membership_spec.rb +9 -12
- data/spec/resource/group_spec.rb +17 -31
- data/spec/resource/linked_account_spec.rb +4 -17
- data/spec/resource/organization_spec.rb +38 -110
- data/spec/resource/password_policy_spec.rb +13 -16
- data/spec/resource/password_strength_spec.rb +15 -18
- data/spec/resource/status_spec.rb +32 -35
- data/spec/spec_helper.rb +8 -139
- data/spec/support/api_key_helpers.rb +34 -0
- data/spec/support/custom_data_storage_behavior.rb +139 -156
- data/spec/support/env_names_warning.rb +59 -0
- data/spec/support/resource_helpers.rb +84 -0
- data/spec/support/resource_matchers.rb +6 -0
- data/stormpath-sdk.gemspec +1 -0
- metadata +20 -3
- data/support/api.rb +0 -55
@@ -1,19 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::PasswordPolicy, :vcr do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:application) { test_api_client.applications.create(build_application) }
|
5
|
+
|
6
|
+
after { application.delete }
|
7
|
+
|
8
|
+
describe 'instances should respond to attribute property methods' do
|
9
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
7
10
|
let(:password_policy) { directory.password_policy }
|
8
11
|
|
9
12
|
before do
|
10
|
-
|
11
|
-
application: application,
|
12
|
-
account_store: directory,
|
13
|
-
list_index: 1,
|
14
|
-
is_default_account_store: false,
|
15
|
-
is_default_group_store: false
|
16
|
-
)
|
13
|
+
map_account_store(application, directory, 1, false, false)
|
17
14
|
end
|
18
15
|
|
19
16
|
after { directory.delete }
|
@@ -42,17 +39,17 @@ describe Stormpath::Resource::PasswordPolicy, :vcr do
|
|
42
39
|
end
|
43
40
|
|
44
41
|
it 'can change reset_email_status' do
|
45
|
-
expect(directory.password_policy.reset_email_status).to eq(
|
46
|
-
password_policy.reset_email_status =
|
42
|
+
expect(directory.password_policy.reset_email_status).to eq('ENABLED')
|
43
|
+
password_policy.reset_email_status = 'DISABLED'
|
47
44
|
password_policy.save
|
48
|
-
expect(directory.password_policy.reset_email_status).to eq(
|
45
|
+
expect(directory.password_policy.reset_email_status).to eq('DISABLED')
|
49
46
|
end
|
50
47
|
|
51
48
|
it 'can change reset_success_email_status' do
|
52
|
-
expect(directory.password_policy.reset_success_email_status).to eq(
|
53
|
-
password_policy.reset_success_email_status =
|
49
|
+
expect(directory.password_policy.reset_success_email_status).to eq('ENABLED')
|
50
|
+
password_policy.reset_success_email_status = 'DISABLED'
|
54
51
|
password_policy.save
|
55
|
-
expect(directory.password_policy.reset_success_email_status).to eq(
|
52
|
+
expect(directory.password_policy.reset_success_email_status).to eq('DISABLED')
|
56
53
|
end
|
57
54
|
end
|
58
55
|
end
|
@@ -1,20 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Stormpath::Resource::PasswordStrength, :vcr do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
let(:application) { test_api_client.applications.create(build_application) }
|
5
|
+
|
6
|
+
after { application.delete }
|
7
|
+
|
8
|
+
describe 'instances should respond to attribute property methods' do
|
9
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
7
10
|
let(:password_policy) { directory.password_policy }
|
8
11
|
let(:password_strength) { password_policy.strength }
|
9
12
|
|
10
13
|
before do
|
11
|
-
|
12
|
-
application: application,
|
13
|
-
account_store: directory,
|
14
|
-
list_index: 1,
|
15
|
-
is_default_account_store: false,
|
16
|
-
is_default_group_store: false
|
17
|
-
)
|
14
|
+
map_account_store(application, directory, 1, false, false)
|
18
15
|
end
|
19
16
|
|
20
17
|
after { directory.delete }
|
@@ -22,14 +19,14 @@ describe Stormpath::Resource::PasswordStrength, :vcr do
|
|
22
19
|
it do
|
23
20
|
expect(password_strength).to be_a Stormpath::Resource::PasswordStrength
|
24
21
|
|
25
|
-
[
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
[:min_length,
|
23
|
+
:max_length,
|
24
|
+
:min_lower_case,
|
25
|
+
:min_upper_case,
|
26
|
+
:min_numeric,
|
27
|
+
:min_symbol,
|
28
|
+
:min_diacritic,
|
29
|
+
:prevent_reuse].each do |property_accessor|
|
33
30
|
expect(password_strength).to respond_to(property_accessor)
|
34
31
|
expect(password_strength).to respond_to("#{property_accessor}=")
|
35
32
|
end
|
@@ -1,67 +1,64 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
describe 'StatusOnDirectoryAndAccount', :vcr do
|
4
|
+
let(:auth_request) do
|
5
|
+
Stormpath::Authentication::UsernamePasswordRequest.new("rubytest#{default_domain}", 'P@$$w0rd')
|
6
|
+
end
|
7
|
+
let(:authenticate_user) do
|
8
|
+
application.authenticate_account(auth_request)
|
9
|
+
end
|
10
|
+
let(:directory) { test_api_client.directories.create(build_directory) }
|
11
|
+
let(:application) { test_api_client.applications.create(build_application) }
|
12
|
+
let(:group) { directory.groups.create(build_group) }
|
13
|
+
let!(:account) do
|
14
|
+
directory.accounts.create(build_account(email: 'rubytest', password: 'P@$$w0rd'))
|
8
15
|
end
|
9
|
-
|
10
|
-
let(:directory) { test_api_client.directories.create name: random_directory_name, description: 'testDirectory for statuses' }
|
11
|
-
|
12
|
-
let(:application) { test_api_client.applications.create name: random_application_name, description: 'testDirectory for statuses' }
|
13
|
-
|
14
|
-
let(:group) { directory.groups.create name: 'testGroup', description: 'testGroup' }
|
15
|
-
|
16
|
-
let(:account_store_mapping) { test_api_client.account_store_mappings.create application: application, account_store: directory }
|
17
|
-
|
18
|
-
let!(:account) { directory.accounts.create email: 'test@example.com', password: 'P@$$w0rd', given_name: "Ruby SDK", surname: 'SDK' }
|
19
|
-
|
20
16
|
let(:reloaded_account) { test_api_client.accounts.get account.href }
|
17
|
+
before { map_account_store(application, directory, 0, true, true) }
|
21
18
|
|
22
19
|
after do
|
23
20
|
application.delete if application
|
24
21
|
directory.delete if directory
|
25
22
|
end
|
26
23
|
|
27
|
-
it
|
28
|
-
expect(directory.respond_to?
|
29
|
-
expect(directory.respond_to?
|
24
|
+
it 'should respond to status getter and setter' do
|
25
|
+
expect(directory.respond_to?(:status)).to be_truthy
|
26
|
+
expect(directory.respond_to?(:status=)).to be_truthy
|
30
27
|
|
31
|
-
expect(application.respond_to?
|
32
|
-
expect(application.respond_to?
|
28
|
+
expect(application.respond_to?(:status)).to be_truthy
|
29
|
+
expect(application.respond_to?(:status=)).to be_truthy
|
33
30
|
|
34
|
-
expect(group.respond_to?
|
35
|
-
expect(group.respond_to?
|
31
|
+
expect(group.respond_to?(:status)).to be_truthy
|
32
|
+
expect(group.respond_to?(:status=)).to be_truthy
|
36
33
|
|
37
|
-
expect(account.respond_to?
|
38
|
-
expect(account.respond_to?
|
34
|
+
expect(account.respond_to?(:status)).to be_truthy
|
35
|
+
expect(account.respond_to?(:status=)).to be_truthy
|
39
36
|
end
|
40
37
|
|
41
|
-
it
|
42
|
-
expect(account.status).to eq(
|
38
|
+
it 'users status by default should be ENABLED' do
|
39
|
+
expect(account.status).to eq('ENABLED')
|
43
40
|
end
|
44
41
|
|
45
|
-
it
|
46
|
-
account.status =
|
42
|
+
it 'change user status' do
|
43
|
+
account.status = 'DISABLED'
|
47
44
|
account.save
|
48
|
-
expect(reloaded_account.status).to eq(
|
45
|
+
expect(reloaded_account.status).to eq('DISABLED')
|
49
46
|
end
|
50
47
|
|
51
|
-
it
|
52
|
-
expect(authenticate_user.properties[
|
48
|
+
it 'authenticate user with status ENABLED' do
|
49
|
+
expect(authenticate_user.properties['account']['href']).to eq(account.href)
|
53
50
|
end
|
54
51
|
|
55
52
|
it "shouldn't authenticate users with status DISABLED, UNVERIFIED or LOCKED" do
|
56
|
-
[
|
53
|
+
['DISABLED', 'UNVERIFIED', 'LOCKED'].each do |status|
|
57
54
|
account.status = status
|
58
55
|
account.save
|
59
|
-
expect{authenticate_user}.to raise_exception(Stormpath::Error)
|
56
|
+
expect { authenticate_user }.to raise_exception(Stormpath::Error)
|
60
57
|
end
|
61
58
|
end
|
62
59
|
|
63
60
|
it 'assigning inappropriate status states should fail silently' do
|
64
|
-
account.status =
|
61
|
+
account.status = 'INVALID_STATUS_VALUE'
|
65
62
|
expect { account.save }.to raise_error(Stormpath::Error)
|
66
63
|
end
|
67
64
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -26,149 +26,18 @@ VCR.configure do |c|
|
|
26
26
|
c.ignore_request { |r| HIJACK_HTTP_REQUESTS_WITH_VCR == false }
|
27
27
|
end
|
28
28
|
|
29
|
-
RSpec::Matchers.define :be_boolean do
|
30
|
-
match do |actual|
|
31
|
-
actual.should satisfy { |x| x == true || x == false }
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
module Stormpath
|
36
|
-
module TestApiKeyHelpers
|
37
|
-
TEST_ENV_REQUIRED_VARS = {
|
38
|
-
STORMPATH_SDK_TEST_API_KEY_ID: 'The id form your Stormpath API Key',
|
39
|
-
STORMPATH_SDK_TEST_API_KEY_SECRET: 'The secret from your Stormpath API Key',
|
40
|
-
STORMPATH_SDK_TEST_APPLICATION_URL: 'The REST URL of a Stormpath Application reserved for testing.',
|
41
|
-
STORMPATH_SDK_TEST_DIRECTORY_URL: 'The REST URL of a Stormpath Directory associated to the test Application.',
|
42
|
-
STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL: 'The REST URL of a Stormpath Directory configured for email verification, associated to the test Application.'
|
43
|
-
}
|
44
|
-
|
45
|
-
def test_api_key_id
|
46
|
-
ENV['STORMPATH_SDK_TEST_API_KEY_ID']
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_api_key_secret
|
50
|
-
ENV['STORMPATH_SDK_TEST_API_KEY_SECRET']
|
51
|
-
end
|
52
|
-
|
53
|
-
def test_directory_url
|
54
|
-
ENV['STORMPATH_SDK_TEST_DIRECTORY_URL']
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_directory_with_verification_url
|
58
|
-
ENV['STORMPATH_SDK_TEST_DIRECTORY_WITH_VERIFICATION_URL']
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_application_url
|
62
|
-
ENV['STORMPATH_SDK_TEST_APPLICATION_URL']
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_api_key
|
66
|
-
Stormpath::ApiKey.new test_api_key_id, test_api_key_secret
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_api_client
|
70
|
-
@test_api_client ||= Stormpath::Client.new api_key: test_api_key
|
71
|
-
end
|
72
|
-
|
73
|
-
def get_cache_data href
|
74
|
-
data_store = test_api_client.send :data_store
|
75
|
-
data_store.send :cache_for, href
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_missing_env_vars
|
79
|
-
TEST_ENV_REQUIRED_VARS.reject do |var, _message|
|
80
|
-
ENV[var.to_s]
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_application
|
85
|
-
test_api_client.applications.get test_application_url
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_directory
|
89
|
-
test_api_client.directories.get test_directory_url
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_directory_with_verification
|
93
|
-
test_api_client.directories.get test_directory_with_verification_url
|
94
|
-
end
|
95
|
-
|
96
|
-
def fixture_path
|
97
|
-
File.expand_path('../fixtures/response', __FILE__)
|
98
|
-
end
|
99
|
-
|
100
|
-
def fixture(file)
|
101
|
-
File.new(fixture_path + '/' + file)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
module TestResourceHelpers
|
106
|
-
def build_account(opts = {})
|
107
|
-
opts.tap do |o|
|
108
|
-
o[:surname] = (!opts[:surname].blank? && opts[:surname]) || 'surname'
|
109
|
-
o[:given_name] = (!opts[:given_name].blank? && opts[:given_name]) || 'givenname'
|
110
|
-
o[:username] = (!opts[:username].blank? && opts[:username]) || random_user_name
|
111
|
-
o[:password] = (!opts[:password].blank? && opts[:password]) || 'P@$$w0rd'
|
112
|
-
o[:email] = (!opts[:email].blank? && opts[:email]) || random_email
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
module RandomResourceNameGenerator
|
118
|
-
include UUIDTools
|
119
|
-
|
120
|
-
%w(application directory organization group user).each do |resource|
|
121
|
-
define_method "random_#{resource}_name" do |suffix = nil|
|
122
|
-
"#{random_string}_#{resource}_#{suffix}"
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
def random_name_key(suffix = 'test')
|
127
|
-
"#{random_string}-namekey-#{suffix}"
|
128
|
-
end
|
129
|
-
|
130
|
-
def random_email
|
131
|
-
"#{random_string}@stormpath.com"
|
132
|
-
end
|
133
|
-
|
134
|
-
def random_string
|
135
|
-
if HIJACK_HTTP_REQUESTS_WITH_VCR
|
136
|
-
'test'
|
137
|
-
else
|
138
|
-
UUID.method(:random_create).call.to_s[0..9]
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
RSpec::Matchers.define :be_boolean do
|
145
|
-
match do |actual|
|
146
|
-
actual == true || actual == false
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
29
|
RSpec.configure do |c|
|
151
|
-
c.mock_with :rspec do |
|
152
|
-
|
30
|
+
c.mock_with :rspec do |cm|
|
31
|
+
cm.syntax = :expect
|
153
32
|
end
|
154
33
|
|
155
|
-
c.expect_with :rspec do |
|
156
|
-
|
34
|
+
c.expect_with :rspec do |ce|
|
35
|
+
ce.syntax = :expect
|
157
36
|
end
|
158
37
|
|
159
|
-
c.include Stormpath::
|
160
|
-
c.include Stormpath::
|
161
|
-
c.include Stormpath::
|
162
|
-
|
163
|
-
c.before(:all) do
|
164
|
-
unless test_missing_env_vars.empty?
|
165
|
-
set_up_message = "In order to run the specs of the Stormpath SDK you need to setup the following environment variables:\n\t"
|
166
|
-
set_up_message << test_missing_env_vars.map do |var, message|
|
167
|
-
"#{var.to_s} : #{message}"
|
168
|
-
end.join("\n\t")
|
169
|
-
set_up_message << "\nBe sure to configure these before running the specs again."
|
170
|
-
raise set_up_message
|
171
|
-
end
|
172
|
-
end
|
38
|
+
c.include Stormpath::Test::ApiKeyHelpers
|
39
|
+
c.include Stormpath::Test::EnvNamesWarning
|
40
|
+
c.include Stormpath::Test::ResourceHelpers
|
173
41
|
|
42
|
+
Stormpath::Test::EnvNamesWarning.check_env_variable_names
|
174
43
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Stormpath
|
2
|
+
module Test
|
3
|
+
module ApiKeyHelpers
|
4
|
+
def test_api_key_id
|
5
|
+
ENV['STORMPATH_CLIENT_APIKEY_ID'] || ENV['STORMPATH_SDK_TEST_API_KEY_ID']
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_api_key_secret
|
9
|
+
ENV['STORMPATH_CLIENT_APIKEY_SECRET'] || ENV['STORMPATH_SDK_TEST_API_KEY_SECRET']
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_api_key
|
13
|
+
Stormpath::ApiKey.new(test_api_key_id, test_api_key_secret)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_api_client
|
17
|
+
@test_api_client ||= Stormpath::Client.new(api_key: test_api_key)
|
18
|
+
end
|
19
|
+
|
20
|
+
def get_cache_data(href)
|
21
|
+
data_store = test_api_client.send :data_store
|
22
|
+
data_store.send :cache_for, href
|
23
|
+
end
|
24
|
+
|
25
|
+
def fixture_path
|
26
|
+
File.expand_path('../../fixtures/response', __FILE__)
|
27
|
+
end
|
28
|
+
|
29
|
+
def fixture(file)
|
30
|
+
File.new(fixture_path + '/' + file)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,33 +1,22 @@
|
|
1
1
|
shared_examples_for 'account_custom_data' do
|
2
2
|
context 'account' do
|
3
|
-
let(:custom_data_storage)
|
4
|
-
directory.accounts.create username: random_user_name,
|
5
|
-
email: random_email,
|
6
|
-
givenName: "Jean-Luc",
|
7
|
-
surname: "Picard",
|
8
|
-
password: "uGhd%a8Kl!"
|
9
|
-
end
|
10
|
-
|
3
|
+
let(:custom_data_storage) { directory.accounts.create(build_account) }
|
11
4
|
let(:custom_data_storage_w_nested_custom_data) do
|
12
|
-
directory.accounts.create
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
let(:reloaded_custom_data_storage) do
|
25
|
-
test_api_client.accounts.get custom_data_storage.href
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:reloaded_custom_data_storage_2) do
|
29
|
-
test_api_client.accounts.get custom_data_storage.href
|
5
|
+
directory.accounts.create(
|
6
|
+
username: 'ruby username',
|
7
|
+
email: "ruby#{default_domain}",
|
8
|
+
given_name: 'Jean-Luc',
|
9
|
+
surname: 'Picard',
|
10
|
+
password: 'uGhd%a8Kl!',
|
11
|
+
custom_data: {
|
12
|
+
rank: 'Captain',
|
13
|
+
favorite_drink: 'Earl Grey Tea',
|
14
|
+
favoriteDrink: 'Camelized Tea'
|
15
|
+
}
|
16
|
+
)
|
30
17
|
end
|
18
|
+
let(:reloaded_custom_data_storage) { test_api_client.accounts.get custom_data_storage.href }
|
19
|
+
let(:reloaded_custom_data_storage_2) { test_api_client.accounts.get custom_data_storage.href }
|
31
20
|
|
32
21
|
it_behaves_like 'custom_data_storage'
|
33
22
|
end
|
@@ -35,40 +24,33 @@ end
|
|
35
24
|
|
36
25
|
shared_examples_for 'group_custom_data' do
|
37
26
|
context 'group' do
|
38
|
-
let(:custom_data_storage)
|
39
|
-
directory.groups.create name: random_group_name
|
40
|
-
end
|
41
|
-
|
27
|
+
let(:custom_data_storage) { directory.groups.create(build_group) }
|
42
28
|
let(:custom_data_storage_w_nested_custom_data) do
|
43
|
-
directory.groups.create
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
let(:reloaded_custom_data_storage) do
|
53
|
-
test_api_client.groups.get custom_data_storage.href
|
29
|
+
directory.groups.create(
|
30
|
+
name: 'ruby group',
|
31
|
+
description: 'Capital Group',
|
32
|
+
custom_data: {
|
33
|
+
rank: 'Captain',
|
34
|
+
favorite_drink: 'Earl Grey Tea',
|
35
|
+
favoriteDrink: 'Camelized Tea'
|
36
|
+
}
|
37
|
+
)
|
54
38
|
end
|
55
39
|
|
56
|
-
let(:
|
57
|
-
|
58
|
-
end
|
40
|
+
let(:reloaded_custom_data_storage) { test_api_client.groups.get custom_data_storage.href }
|
41
|
+
let(:reloaded_custom_data_storage_2) { test_api_client.groups.get custom_data_storage.href }
|
59
42
|
|
60
43
|
it_behaves_like 'custom_data_storage'
|
61
44
|
end
|
62
45
|
end
|
63
46
|
|
64
|
-
RESERVED_FIELDS = %w(
|
47
|
+
RESERVED_FIELDS = %w(createdAt modifiedAt meta spMeta spmeta ionMeta ionmeta).freeze
|
65
48
|
|
66
49
|
shared_examples_for 'custom_data_storage' do
|
67
|
-
|
68
50
|
it 'read reserved data' do
|
69
|
-
expect(custom_data_storage.custom_data[
|
70
|
-
expect(custom_data_storage.custom_data[
|
71
|
-
expect(custom_data_storage.custom_data[
|
51
|
+
expect(custom_data_storage.custom_data['href']).not_to eq(nil)
|
52
|
+
expect(custom_data_storage.custom_data['createdAt']).not_to eq(nil)
|
53
|
+
expect(custom_data_storage.custom_data['modifiedAt']).not_to eq(nil)
|
72
54
|
end
|
73
55
|
|
74
56
|
it 'getters for timestamps work' do
|
@@ -79,30 +61,30 @@ shared_examples_for 'custom_data_storage' do
|
|
79
61
|
RESERVED_FIELDS.each do |reserved_field|
|
80
62
|
it "set reserved data #{reserved_field} should raise error" do
|
81
63
|
custom_data_storage.custom_data[reserved_field] = 12
|
82
|
-
expect{ custom_data_storage.custom_data.save }.to raise_error Stormpath::Error
|
64
|
+
expect { custom_data_storage.custom_data.save }.to raise_error Stormpath::Error
|
83
65
|
end
|
84
66
|
end
|
85
67
|
|
86
68
|
it 'should save properly when custom data is nested on creation' do
|
87
|
-
expect(custom_data_storage_w_nested_custom_data.custom_data[
|
88
|
-
expect(custom_data_storage_w_nested_custom_data.custom_data[
|
89
|
-
expect(custom_data_storage_w_nested_custom_data.custom_data[
|
69
|
+
expect(custom_data_storage_w_nested_custom_data.custom_data['rank']).to eq('Captain')
|
70
|
+
expect(custom_data_storage_w_nested_custom_data.custom_data['favorite_drink']).to eq('Earl Grey Tea')
|
71
|
+
expect(custom_data_storage_w_nested_custom_data.custom_data['favoriteDrink']).to eq('Camelized Tea')
|
90
72
|
end
|
91
73
|
|
92
74
|
it 'set custom data' do
|
93
|
-
custom_data_storage.custom_data[:rank] =
|
94
|
-
expect(custom_data_storage.custom_data[:rank]).to eq(
|
75
|
+
custom_data_storage.custom_data[:rank] = 'Captain'
|
76
|
+
expect(custom_data_storage.custom_data[:rank]).to eq('Captain')
|
95
77
|
custom_data_storage.custom_data.save
|
96
|
-
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq(
|
78
|
+
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq('Captain')
|
97
79
|
end
|
98
80
|
|
99
81
|
it 'set nested custom data' do
|
100
|
-
custom_data_storage.custom_data[:special_rank] =
|
101
|
-
custom_data_storage.custom_data[:permissions] = {
|
102
|
-
expect(custom_data_storage.custom_data[:permissions]).to eq(
|
82
|
+
custom_data_storage.custom_data[:special_rank] = 'Captain'
|
83
|
+
custom_data_storage.custom_data[:permissions] = { 'crew_quarters' => '93-601' }
|
84
|
+
expect(custom_data_storage.custom_data[:permissions]).to eq('crew_quarters' => '93-601')
|
103
85
|
custom_data_storage.custom_data.save
|
104
|
-
expect(reloaded_custom_data_storage.custom_data[:special_rank]).to eq(
|
105
|
-
expect(reloaded_custom_data_storage.custom_data[:permissions]).to eq(
|
86
|
+
expect(reloaded_custom_data_storage.custom_data[:special_rank]).to eq('Captain')
|
87
|
+
expect(reloaded_custom_data_storage.custom_data[:permissions]).to eq('crew_quarters' => '93-601')
|
106
88
|
end
|
107
89
|
|
108
90
|
it 'not raise errors when saving a empty properties array' do
|
@@ -110,166 +92,165 @@ shared_examples_for 'custom_data_storage' do
|
|
110
92
|
end
|
111
93
|
|
112
94
|
it 'trigger custom data saving on custom_data_storage.save' do
|
113
|
-
custom_data_storage.custom_data[:rank] =
|
95
|
+
custom_data_storage.custom_data[:rank] = 'Captain'
|
114
96
|
custom_data_storage.save
|
115
|
-
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq(
|
97
|
+
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq('Captain')
|
116
98
|
end
|
117
99
|
|
118
100
|
it 'trigger custom data saving on custom_data_storage.save with complex custom data' do
|
119
|
-
custom_data_storage.custom_data[:permissions] = {
|
101
|
+
custom_data_storage.custom_data[:permissions] = { 'crew_quarters' => '93-601' }
|
120
102
|
custom_data_storage.save
|
121
|
-
expect(reloaded_custom_data_storage.custom_data[:permissions]).to eq(
|
103
|
+
expect(reloaded_custom_data_storage.custom_data[:permissions]).to eq('crew_quarters' => '93-601')
|
122
104
|
end
|
123
105
|
|
124
106
|
it 'update custom data through custom_data_storage.save, cache should be cleared' do
|
125
|
-
custom_data_storage.custom_data[:permissions] = {
|
107
|
+
custom_data_storage.custom_data[:permissions] = {'crew_quarters' => '93-601'}
|
126
108
|
custom_data_storage.custom_data.save
|
127
109
|
|
128
|
-
expect(reloaded_custom_data_storage.custom_data[:permissions]).to eq(
|
110
|
+
expect(reloaded_custom_data_storage.custom_data[:permissions]).to eq('crew_quarters' => '93-601')
|
129
111
|
|
130
|
-
reloaded_custom_data_storage.custom_data[:permissions] = {
|
112
|
+
reloaded_custom_data_storage.custom_data[:permissions] = { 'crew_quarters' => '601-93' }
|
131
113
|
|
132
114
|
reloaded_custom_data_storage.save
|
133
|
-
expect(reloaded_custom_data_storage_2.custom_data[:permissions]).to eq(
|
115
|
+
expect(reloaded_custom_data_storage_2.custom_data[:permissions]).to eq('crew_quarters' => '601-93')
|
134
116
|
end
|
135
117
|
|
136
118
|
it 'first level keys can be saved as symbols or strings, they will default to the same (saved as strings)' do
|
137
|
-
custom_data_storage.custom_data[:permissions] =
|
138
|
-
expect(custom_data_storage.custom_data[:permissions]).to eq(
|
139
|
-
expect(custom_data_storage.custom_data[
|
119
|
+
custom_data_storage.custom_data[:permissions] = 'Drive the boat'
|
120
|
+
expect(custom_data_storage.custom_data[:permissions]).to eq('Drive the boat');
|
121
|
+
expect(custom_data_storage.custom_data['permissions']).to eq(custom_data_storage.custom_data[:permissions])
|
140
122
|
|
141
123
|
custom_data_storage.custom_data.save
|
142
|
-
expect(custom_data_storage.custom_data[:permissions]).to eq(
|
143
|
-
expect(custom_data_storage.custom_data[
|
124
|
+
expect(custom_data_storage.custom_data[:permissions]).to eq('Drive the boat');
|
125
|
+
expect(custom_data_storage.custom_data['permissions']).to eq(custom_data_storage.custom_data[:permissions])
|
144
126
|
end
|
145
127
|
|
146
128
|
it "one shouldn't save deeply nested keys as symbols, as on return from the server they will be strings" do
|
147
|
-
custom_data_storage.custom_data[:permissions] = { driving_privelage:
|
148
|
-
expect(custom_data_storage.custom_data[:permissions]).to eq(
|
129
|
+
custom_data_storage.custom_data[:permissions] = { driving_privelage: 'Boat', can_swim: true }
|
130
|
+
expect(custom_data_storage.custom_data[:permissions]).to eq(driving_privelage: 'Boat', can_swim: true)
|
149
131
|
custom_data_storage.custom_data.save
|
150
|
-
expect(custom_data_storage.custom_data[:permissions]).to eq(
|
151
|
-
expect(custom_data_storage.custom_data[:permissions]).not_to eq(
|
132
|
+
expect(custom_data_storage.custom_data[:permissions]).to eq('driving_privelage' => 'Boat', 'can_swim' => true)
|
133
|
+
expect(custom_data_storage.custom_data[:permissions]).not_to eq(driving_privelage: 'Boat', can_swim: true)
|
152
134
|
end
|
153
135
|
|
154
136
|
it 'delete all custom data and rebind without reloading' do
|
155
|
-
custom_data_storage.custom_data[
|
137
|
+
custom_data_storage.custom_data['a_map'] = { the_key: 'this is the value' }
|
156
138
|
custom_data_storage.custom_data.save
|
157
139
|
|
158
|
-
expect(custom_data_storage.custom_data[
|
140
|
+
expect(custom_data_storage.custom_data['a_map']).to eq('the_key' => 'this is the value')
|
159
141
|
|
160
|
-
custom_data_storage.custom_data.delete(
|
142
|
+
custom_data_storage.custom_data.delete('a_map')
|
161
143
|
custom_data_storage.custom_data.save
|
162
144
|
|
163
|
-
expect(custom_data_storage.custom_data[
|
145
|
+
expect(custom_data_storage.custom_data['a_map']).to be_nil
|
164
146
|
|
165
|
-
custom_data_storage.custom_data[
|
147
|
+
custom_data_storage.custom_data['rank'] = 'Captain'
|
166
148
|
custom_data_storage.custom_data.save
|
167
149
|
|
168
|
-
expect(custom_data_storage.custom_data[
|
150
|
+
expect(custom_data_storage.custom_data['rank']).to eq('Captain')
|
169
151
|
|
170
152
|
custom_data_storage.custom_data.delete
|
171
153
|
|
172
|
-
expect(custom_data_storage.custom_data[
|
173
|
-
expect(custom_data_storage.custom_data[
|
154
|
+
expect(custom_data_storage.custom_data['a_map']).to be_nil
|
155
|
+
expect(custom_data_storage.custom_data['rank']).to be_nil
|
174
156
|
|
175
|
-
custom_data_storage.custom_data['new_stuff'] =
|
157
|
+
custom_data_storage.custom_data['new_stuff'] = 'the value'
|
176
158
|
custom_data_storage.custom_data.save
|
177
159
|
|
178
|
-
expect(custom_data_storage.custom_data[
|
179
|
-
custom_data_storage.custom_data.delete(
|
160
|
+
expect(custom_data_storage.custom_data['new_stuff']).to eq('the value')
|
161
|
+
custom_data_storage.custom_data.delete('new_stuff')
|
180
162
|
|
181
163
|
custom_data_storage.custom_data.save
|
182
164
|
|
183
|
-
expect(custom_data_storage.custom_data[
|
165
|
+
expect(custom_data_storage.custom_data['new_stuff']).to be_nil
|
184
166
|
end
|
185
167
|
|
186
168
|
it 'delete all custom data and rebind without reloading through custom_data_storage#save' do
|
187
|
-
custom_data_storage.custom_data[
|
169
|
+
custom_data_storage.custom_data['a_map'] = { 'the_key' => 'this is the value' }
|
188
170
|
custom_data_storage.save
|
189
171
|
|
190
|
-
expect(custom_data_storage.custom_data[
|
172
|
+
expect(custom_data_storage.custom_data['a_map']).to eq('the_key' => 'this is the value')
|
191
173
|
|
192
|
-
custom_data_storage.custom_data.delete(
|
174
|
+
custom_data_storage.custom_data.delete('a_map')
|
193
175
|
custom_data_storage.custom_data.save
|
194
176
|
|
195
|
-
expect(custom_data_storage.custom_data[
|
177
|
+
expect(custom_data_storage.custom_data['a_map']).to be_nil
|
196
178
|
|
197
|
-
custom_data_storage.custom_data[
|
179
|
+
custom_data_storage.custom_data['rank'] = 'Captain'
|
198
180
|
custom_data_storage.save
|
199
181
|
|
200
|
-
expect(custom_data_storage.custom_data[
|
182
|
+
expect(custom_data_storage.custom_data['rank']).to eq('Captain')
|
201
183
|
|
202
184
|
custom_data_storage.custom_data.delete
|
203
185
|
|
204
|
-
expect(custom_data_storage.custom_data[
|
205
|
-
expect(custom_data_storage.custom_data[
|
186
|
+
expect(custom_data_storage.custom_data['a_map']).to be_nil
|
187
|
+
expect(custom_data_storage.custom_data['rank']).to be_nil
|
206
188
|
|
207
|
-
custom_data_storage.custom_data['new_stuff'] =
|
189
|
+
custom_data_storage.custom_data['new_stuff'] = 'the value'
|
208
190
|
custom_data_storage.save
|
209
191
|
|
210
|
-
expect(custom_data_storage.custom_data[
|
192
|
+
expect(custom_data_storage.custom_data['new_stuff']).to eq('the value')
|
211
193
|
|
212
|
-
custom_data_storage.custom_data.delete(
|
194
|
+
custom_data_storage.custom_data.delete('new_stuff')
|
213
195
|
custom_data_storage.custom_data.save
|
214
196
|
|
215
|
-
expect(custom_data_storage.custom_data[
|
197
|
+
expect(custom_data_storage.custom_data['new_stuff']).to be_nil
|
216
198
|
end
|
217
199
|
|
218
200
|
it 'delete all custom data' do
|
219
|
-
custom_data_storage.custom_data[:rank] =
|
201
|
+
custom_data_storage.custom_data[:rank] = 'Captain'
|
220
202
|
custom_data_storage.custom_data.save
|
221
|
-
expect(custom_data_storage.custom_data[:rank]).to eq(
|
203
|
+
expect(custom_data_storage.custom_data[:rank]).to eq('Captain')
|
222
204
|
custom_data_storage.custom_data.delete
|
223
205
|
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq(nil)
|
224
206
|
end
|
225
207
|
|
226
208
|
it 'delete all custom data and re-add new custom data' do
|
227
|
-
custom_data_storage.custom_data[:rank] =
|
209
|
+
custom_data_storage.custom_data[:rank] = 'Captain'
|
228
210
|
|
229
211
|
custom_data_storage.custom_data.save
|
230
212
|
|
231
|
-
expect(custom_data_storage.custom_data[:rank]).to eq(
|
213
|
+
expect(custom_data_storage.custom_data[:rank]).to eq('Captain')
|
232
214
|
|
233
215
|
custom_data_storage.custom_data.delete
|
234
216
|
|
235
217
|
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq(nil)
|
236
218
|
|
237
|
-
reloaded_custom_data_storage.custom_data[:rank] =
|
219
|
+
reloaded_custom_data_storage.custom_data[:rank] = 'Pilot'
|
238
220
|
|
239
221
|
reloaded_custom_data_storage.custom_data.save
|
240
222
|
|
241
|
-
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq(
|
223
|
+
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq('Pilot')
|
242
224
|
|
243
|
-
expect(reloaded_custom_data_storage_2.custom_data[:rank]).to eq(
|
225
|
+
expect(reloaded_custom_data_storage_2.custom_data[:rank]).to eq('Pilot')
|
244
226
|
end
|
245
227
|
|
246
228
|
it "shouldn't be the same if the key is lowercased or camelcased" do
|
229
|
+
favorite_drink = 'Earl Grey Tea'
|
230
|
+
custom_data_storage.custom_data['favorite_drink'] = favorite_drink
|
247
231
|
|
248
|
-
favorite_drink
|
249
|
-
custom_data_storage.custom_data[
|
250
|
-
|
251
|
-
expect(custom_data_storage.custom_data["favorite_drink"]).to eq(favorite_drink)
|
252
|
-
expect(custom_data_storage.custom_data["favoriteDrink"]).to be_nil
|
232
|
+
expect(custom_data_storage.custom_data['favorite_drink']).to eq(favorite_drink)
|
233
|
+
expect(custom_data_storage.custom_data['favoriteDrink']).to be_nil
|
253
234
|
|
254
235
|
custom_data_storage.custom_data.save
|
255
236
|
|
256
|
-
expect(custom_data_storage.custom_data[
|
257
|
-
expect(custom_data_storage.custom_data[
|
237
|
+
expect(custom_data_storage.custom_data['favorite_drink']).to eq(favorite_drink)
|
238
|
+
expect(custom_data_storage.custom_data['favoriteDrink']).to be_nil
|
258
239
|
|
259
|
-
custom_data_storage.custom_data.delete(
|
240
|
+
custom_data_storage.custom_data.delete('favorite_drink')
|
260
241
|
|
261
|
-
expect(custom_data_storage.custom_data[
|
262
|
-
expect(custom_data_storage.custom_data[
|
242
|
+
expect(custom_data_storage.custom_data['favorite_drink']).to be_nil
|
243
|
+
expect(custom_data_storage.custom_data['favoriteDrink']).to be_nil
|
263
244
|
|
264
245
|
custom_data_storage.custom_data.save
|
265
246
|
|
266
|
-
expect(custom_data_storage.custom_data[
|
267
|
-
expect(custom_data_storage.custom_data[
|
247
|
+
expect(custom_data_storage.custom_data['favorite_drink']).to be_nil
|
248
|
+
expect(custom_data_storage.custom_data['favoriteDrink']).to be_nil
|
268
249
|
end
|
269
250
|
|
270
251
|
it 'delete a specific custom data field' do
|
271
|
-
custom_data_storage.custom_data[:rank] =
|
272
|
-
custom_data_storage.custom_data[
|
252
|
+
custom_data_storage.custom_data[:rank] = 'Captain'
|
253
|
+
custom_data_storage.custom_data['favorite_drink'] = 'Earl Grey Tea'
|
273
254
|
custom_data_storage.custom_data.save
|
274
255
|
|
275
256
|
custom_data_storage.custom_data.delete(:rank)
|
@@ -277,79 +258,81 @@ shared_examples_for 'custom_data_storage' do
|
|
277
258
|
|
278
259
|
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq(nil)
|
279
260
|
|
280
|
-
expect(reloaded_custom_data_storage.custom_data[
|
261
|
+
expect(reloaded_custom_data_storage.custom_data['favorite_drink']).to eq('Earl Grey Tea')
|
281
262
|
end
|
282
263
|
|
283
264
|
|
284
265
|
it '#has_key?' do
|
285
|
-
expect(custom_data_storage.custom_data.has_key?
|
286
|
-
expect(custom_data_storage.custom_data.has_key?
|
266
|
+
expect(custom_data_storage.custom_data.has_key?('createdAt')).to be_truthy
|
267
|
+
expect(custom_data_storage.custom_data.has_key?('created_at')).to be_falsey
|
287
268
|
end
|
288
269
|
|
289
270
|
it '#include?' do
|
290
|
-
expect(custom_data_storage.custom_data.include?
|
291
|
-
expect(custom_data_storage.custom_data.include?
|
271
|
+
expect(custom_data_storage.custom_data.include?('createdAt')).to be_truthy
|
272
|
+
expect(custom_data_storage.custom_data.include?('created_at')).to be_falsey
|
292
273
|
end
|
293
274
|
|
294
275
|
it '#has_value?' do
|
295
|
-
custom_data_storage.custom_data[:rank] =
|
276
|
+
custom_data_storage.custom_data[:rank] = 'Captain'
|
296
277
|
custom_data_storage.custom_data.save
|
297
|
-
expect(reloaded_custom_data_storage.custom_data.has_value?
|
278
|
+
expect(reloaded_custom_data_storage.custom_data.has_value?('Captain')).to be_truthy
|
298
279
|
end
|
299
280
|
|
300
281
|
it '#store' do
|
301
|
-
custom_data_storage.custom_data.store(:rank,
|
282
|
+
custom_data_storage.custom_data.store(:rank, 'Captain')
|
302
283
|
custom_data_storage.custom_data.save
|
303
|
-
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq(
|
284
|
+
expect(reloaded_custom_data_storage.custom_data[:rank]).to eq('Captain')
|
304
285
|
end
|
305
286
|
|
306
287
|
it '#store with a snakecased key' do
|
307
|
-
custom_data_storage.custom_data.store(:super_rank,
|
288
|
+
custom_data_storage.custom_data.store(:super_rank, 'Captain')
|
308
289
|
|
309
|
-
expect(custom_data_storage.custom_data[:super_rank]).to eq(
|
310
|
-
expect(custom_data_storage.custom_data[
|
290
|
+
expect(custom_data_storage.custom_data[:super_rank]).to eq('Captain')
|
291
|
+
expect(custom_data_storage.custom_data['super_rank']).to eq('Captain')
|
311
292
|
|
312
293
|
expect(custom_data_storage.custom_data[:superRank]).to be_nil
|
313
|
-
expect(custom_data_storage.custom_data[
|
294
|
+
expect(custom_data_storage.custom_data['superRank']).to be_nil
|
314
295
|
|
315
296
|
custom_data_storage.custom_data.save
|
316
297
|
|
317
|
-
expect(custom_data_storage.custom_data[:super_rank]).to eq(
|
318
|
-
expect(custom_data_storage.custom_data[
|
298
|
+
expect(custom_data_storage.custom_data[:super_rank]).to eq('Captain')
|
299
|
+
expect(custom_data_storage.custom_data['super_rank']).to eq('Captain')
|
319
300
|
|
320
301
|
expect(custom_data_storage.custom_data[:superRank]).to be_nil
|
321
|
-
expect(custom_data_storage.custom_data[
|
302
|
+
expect(custom_data_storage.custom_data['superRank']).to be_nil
|
322
303
|
end
|
323
304
|
|
324
|
-
|
325
|
-
custom_data_storage.custom_data.store(:superRank,
|
305
|
+
it '#store with a lower camelCase key' do
|
306
|
+
custom_data_storage.custom_data.store(:superRank, 'Captain')
|
326
307
|
|
327
|
-
expect(custom_data_storage.custom_data[:superRank]).to eq(
|
328
|
-
expect(custom_data_storage.custom_data[
|
308
|
+
expect(custom_data_storage.custom_data[:superRank]).to eq('Captain')
|
309
|
+
expect(custom_data_storage.custom_data['superRank']).to eq('Captain')
|
329
310
|
|
330
311
|
expect(custom_data_storage.custom_data[:super_rank]).to be_nil
|
331
|
-
expect(custom_data_storage.custom_data[
|
312
|
+
expect(custom_data_storage.custom_data['super_rank']).to be_nil
|
332
313
|
|
333
314
|
custom_data_storage.custom_data.save
|
334
315
|
|
335
|
-
expect(custom_data_storage.custom_data[:superRank]).to eq(
|
336
|
-
expect(custom_data_storage.custom_data[
|
316
|
+
expect(custom_data_storage.custom_data[:superRank]).to eq('Captain')
|
317
|
+
expect(custom_data_storage.custom_data['superRank']).to eq('Captain')
|
337
318
|
|
338
319
|
expect(custom_data_storage.custom_data[:super_rank]).to be_nil
|
339
|
-
expect(custom_data_storage.custom_data[
|
320
|
+
expect(custom_data_storage.custom_data['super_rank']).to be_nil
|
340
321
|
end
|
341
322
|
|
342
323
|
it '#keys' do
|
343
324
|
expect(custom_data_storage.custom_data.keys).to be_kind_of(Array)
|
344
325
|
expect(custom_data_storage.custom_data.keys.count).to eq(3)
|
345
|
-
expect(custom_data_storage.custom_data.keys)
|
326
|
+
expect(custom_data_storage.custom_data.keys)
|
327
|
+
.to eq(custom_data_storage.custom_data.properties.keys)
|
346
328
|
end
|
347
329
|
|
348
330
|
it '#values' do
|
349
|
-
custom_data_storage.custom_data[:permissions] = {
|
331
|
+
custom_data_storage.custom_data[:permissions] = { 'crew_quarters' => '93-601' }
|
350
332
|
custom_data_storage.custom_data.save
|
351
|
-
expect(reloaded_custom_data_storage.custom_data.values).to include(
|
352
|
-
expect(reloaded_custom_data_storage.custom_data.values)
|
333
|
+
expect(reloaded_custom_data_storage.custom_data.values).to include('crew_quarters' => '93-601')
|
334
|
+
expect(reloaded_custom_data_storage.custom_data.values)
|
335
|
+
.to eq(reloaded_custom_data_storage.custom_data.properties.values)
|
353
336
|
end
|
354
337
|
|
355
338
|
it 'inner property holders clearing properly' do
|
@@ -359,7 +342,7 @@ shared_examples_for 'custom_data_storage' do
|
|
359
342
|
|
360
343
|
custom_data_storage.custom_data.save
|
361
344
|
|
362
|
-
expect(custom_data_storage.custom_data[:permissions]).to eq(
|
345
|
+
expect(custom_data_storage.custom_data[:permissions]).to eq('NOOP')
|
363
346
|
custom_data_storage.custom_data.delete(:permissions)
|
364
347
|
expect(custom_data_storage.custom_data[:permissions]).to be_nil
|
365
348
|
|
@@ -371,7 +354,7 @@ shared_examples_for 'custom_data_storage' do
|
|
371
354
|
expect(deleted_properties.count).to eq(0)
|
372
355
|
|
373
356
|
custom_data_storage.custom_data[:permissions] = 'NOOP'
|
374
|
-
expect(custom_data_storage.custom_data[:permissions]).to eq(
|
357
|
+
expect(custom_data_storage.custom_data[:permissions]).to eq('NOOP')
|
375
358
|
|
376
359
|
custom_data_storage.custom_data.delete(:permissions)
|
377
360
|
expect(custom_data_storage.custom_data[:permissions]).to be_nil
|
@@ -379,9 +362,9 @@ shared_examples_for 'custom_data_storage' do
|
|
379
362
|
expect(deleted_properties.count).to eq(1)
|
380
363
|
|
381
364
|
if custom_data_storage.is_a? Stormpath::Resource::Account
|
382
|
-
custom_data_storage.given_name =
|
365
|
+
custom_data_storage.given_name = 'Capt'
|
383
366
|
else
|
384
|
-
custom_data_storage.name = random_group_name
|
367
|
+
custom_data_storage.name = 'random_group_name'
|
385
368
|
end
|
386
369
|
|
387
370
|
custom_data_storage.save
|
@@ -391,6 +374,6 @@ shared_examples_for 'custom_data_storage' do
|
|
391
374
|
end
|
392
375
|
|
393
376
|
def deleted_properties
|
394
|
-
custom_data_storage.custom_data.instance_variable_get(
|
377
|
+
custom_data_storage.custom_data.instance_variable_get('@deleted_properties')
|
395
378
|
end
|
396
379
|
end
|