iugusdk 1.0.0.alpha.3 → 1.0.0.alpha.4
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.
- data/app/controllers/iugu/account_controller.rb +14 -5
- data/app/controllers/iugu/pricing_controller.rb +8 -0
- data/app/controllers/iugu/profile_controller.rb +15 -2
- data/app/controllers/iugu/registrations_controller.rb +8 -0
- data/app/controllers/iugu/sessions_controller.rb +8 -0
- data/app/models/account.rb +1 -13
- data/app/models/api_token.rb +32 -0
- data/app/models/user.rb +25 -0
- data/app/views/iugu/pricing/index.html.haml +14 -0
- data/app/views/iugu/settings/account.html.haml +21 -6
- data/app/views/iugu/settings/profile.html.haml +11 -1
- data/config/locales/iugu.en.yml +5 -1
- data/config/locales/iugu.pt-BR.yml +5 -1
- data/config/routes.rb +3 -0
- data/db/migrate/20121023113304_create_api_token.rb +15 -0
- data/lib/iugusdk/engine.rb +8 -0
- data/lib/iugusdk/iugusdk_base_controller.rb +16 -7
- data/lib/iugusdk/root_tenancy_url.rb +3 -3
- data/lib/iugusdk/session_parameter_middleware.rb +15 -0
- data/lib/iugusdk/version.rb +1 -1
- data/lib/iugusdk.rb +17 -0
- data/spec/controllers/account_controller_spec.rb +19 -8
- data/spec/controllers/pricing_controller_spec.rb +16 -0
- data/spec/controllers/profile_controller_spec.rb +13 -4
- data/spec/controllers/registration_controller_spec.rb +15 -1
- data/spec/dummy/config/application.rb +4 -1
- data/spec/dummy/config/initializers/iugusdk.rb +2 -0
- data/spec/dummy/db/migrate/20121108115535_remove_api_token_from_account.rb +7 -0
- data/spec/dummy/db/schema.rb +11 -1
- data/spec/dummy/log/development.log +2967 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CF1/A70/sprockets%2F368a631d9662bcc4891c91f739b7be37 +0 -0
- data/spec/dummy/tmp/cache/assets/CF6/A50/sprockets%2Ff434c1ed5d55916f790cf698832f76b1 +0 -0
- data/spec/dummy/tmp/cache/assets/CF9/650/sprockets%2F5767184d0e9646ef1aec88c89a47b761 +0 -0
- data/spec/dummy/tmp/cache/assets/D12/D70/sprockets%2F9c37ed72a191cf588665dcb621f401c3 +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/D77/920/sprockets%2Faf0e746c541e6cf4540db92c87da579c +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/410/sprockets%2F91b38c54838c97f0815ebf8aabddfc4e +0 -0
- data/spec/dummy/tmp/cache/assets/E01/940/sprockets%2F5fe65d209f8e909c4f3b080fceacac1e +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/sass/e35248e21fc26dee07372931d609e6a972a6818c/default.sassc +0 -0
- data/spec/fabricators/api_token_fabricator.rb +5 -0
- data/spec/models/account_spec.rb +0 -33
- data/spec/models/api_token_spec.rb +23 -0
- data/spec/models/user_spec.rb +9 -0
- data/spec/requests/account_spec.rb +19 -5
- data/spec/requests/user_spec.rb +18 -1
- metadata +289 -416
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/models/account_spec.rb
CHANGED
@@ -9,7 +9,6 @@ describe Account do
|
|
9
9
|
it { should have_many(:account_users) }
|
10
10
|
it { should have_many(:users).through(:account_users) }
|
11
11
|
it { should validate_uniqueness_of(:subdomain) }
|
12
|
-
it { should validate_uniqueness_of(:api_token) }
|
13
12
|
|
14
13
|
it "should return true for a valid user of account" do
|
15
14
|
@user = Fabricate(:user, :email => "me@me.com")
|
@@ -23,11 +22,6 @@ describe Account do
|
|
23
22
|
@account = Fabricate.build(:account) { subdomain "subdominio" }.should_not be_valid
|
24
23
|
end
|
25
24
|
|
26
|
-
it 'should set api_token before create' do
|
27
|
-
@account = Fabricate(:account)
|
28
|
-
@account.api_token.should_not be_nil
|
29
|
-
end
|
30
|
-
|
31
25
|
it 'should set subdomain before create' do
|
32
26
|
@account = Fabricate(:account)
|
33
27
|
@account.reload
|
@@ -166,31 +160,4 @@ describe Account do
|
|
166
160
|
Account.get_from_domain("notused.domain.test").should be_nil
|
167
161
|
end
|
168
162
|
end
|
169
|
-
|
170
|
-
context "generate_api_token" do
|
171
|
-
before(:each) do
|
172
|
-
@account = Fabricate(:account)
|
173
|
-
end
|
174
|
-
|
175
|
-
it 'should return a new token' do
|
176
|
-
old_token = @account.api_token
|
177
|
-
@account.send(:generate_api_token).should_not == old_token
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
context "update_api_token" do
|
183
|
-
before(:each) do
|
184
|
-
@account = Fabricate(:account)
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'should replace api_token' do
|
188
|
-
old_token = @account.api_token
|
189
|
-
@account.update_api_token
|
190
|
-
@account.api_token.should_not == old_token
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|
194
|
-
|
195
|
-
|
196
163
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ApiToken do
|
4
|
+
before(:each) do
|
5
|
+
IuguSDK::account_api_tokens = [ 'test', 'live' ]
|
6
|
+
Fabricate(:api_token)
|
7
|
+
end
|
8
|
+
|
9
|
+
it { should validate_uniqueness_of(:token) }
|
10
|
+
it { should validate_presence_of(:description) }
|
11
|
+
it { should validate_presence_of(:tokenable) }
|
12
|
+
|
13
|
+
it 'description should be unique for each tokenable record' do
|
14
|
+
@acc = Fabricate(:account)
|
15
|
+
@acc.tokens.create(description: "token 1", api_type: 'test').should be_valid
|
16
|
+
@acc.tokens.create(description: "token 1", api_type: 'live').should_not be_valid
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'api_type should be supported' do
|
20
|
+
Fabricate.build(:api_token, api_type: 'not supported').should_not be_valid
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -9,6 +9,15 @@ describe User do
|
|
9
9
|
it { should have_many(:social_accounts) }
|
10
10
|
it { should validate_presence_of(:email) }
|
11
11
|
|
12
|
+
context "when enable_user_api = true" do
|
13
|
+
before(:each) { IuguSDK::enable_user_api = true }
|
14
|
+
|
15
|
+
it 'should have a token' do
|
16
|
+
Fabricate(:user).token.should_not be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
12
21
|
context "after create" do
|
13
22
|
#it 'should create an account with subdomain' do
|
14
23
|
#@user = Fabricate(:user) do
|
@@ -64,6 +64,8 @@ describe 'accounts settings view' do
|
|
64
64
|
IuguSDK::enable_custom_domain = true
|
65
65
|
IuguSDK::enable_account_alias = true
|
66
66
|
IuguSDK::enable_account_api = true
|
67
|
+
IuguSDK::account_api_tokens = ['test', 'live']
|
68
|
+
IuguSDK::enable_account_cancel = true
|
67
69
|
end
|
68
70
|
|
69
71
|
context "when enable_multiple_users_per_account == true" do
|
@@ -103,14 +105,28 @@ describe 'accounts settings view' do
|
|
103
105
|
end
|
104
106
|
it { page.should have_link I18n.t("iugu.manage") }
|
105
107
|
|
106
|
-
it { page.should have_link I18n.t("iugu.cancel_account") }
|
107
|
-
|
108
108
|
it { page.should have_content @target_account.api_token }
|
109
109
|
|
110
|
-
it { page.should
|
110
|
+
it { page.should have_content I18n.t("iugu.api_tokens") }
|
111
111
|
|
112
112
|
it { page.should have_field 'account[name]' }
|
113
113
|
|
114
|
+
context "when enable_account_cancel == true" do
|
115
|
+
before(:each) do
|
116
|
+
IuguSDK::enable_account_cancel = true
|
117
|
+
visit account_view_path(@target_account.id)
|
118
|
+
end
|
119
|
+
it { page.should have_link I18n.t("iugu.cancel_account") }
|
120
|
+
end
|
121
|
+
|
122
|
+
context "when enable_account_cancel == false" do
|
123
|
+
before(:each) do
|
124
|
+
IuguSDK::enable_account_cancel = false
|
125
|
+
visit account_view_path(@target_account.id)
|
126
|
+
end
|
127
|
+
it { page.should_not have_link I18n.t("iugu.cancel_account") }
|
128
|
+
end
|
129
|
+
|
114
130
|
context "when account is being canceled" do
|
115
131
|
context "if delay_account_exclusion == 0" do
|
116
132
|
before(:each) do
|
@@ -148,8 +164,6 @@ describe 'accounts settings view' do
|
|
148
164
|
|
149
165
|
it { page.should_not have_link I18n.t("iugu.cancel_account") }
|
150
166
|
|
151
|
-
it { page.should_not have_content @target_account.api_token }
|
152
|
-
|
153
167
|
it { page.should_not have_link I18n.t("iugu.generate_new_token") }
|
154
168
|
|
155
169
|
end
|
data/spec/requests/user_spec.rb
CHANGED
@@ -4,13 +4,30 @@ describe 'account settings view' do
|
|
4
4
|
before(:each) do
|
5
5
|
IuguSDK::enable_social_login = true
|
6
6
|
IuguSDK::enable_social_linking = true
|
7
|
+
IuguSDK::enable_user_cancel = true
|
7
8
|
visit '/account/auth/facebook'
|
8
9
|
visit profile_settings_path
|
9
10
|
end
|
10
11
|
|
11
|
-
it { page.should have_link I18n.t("iugu.remove_user") }
|
12
12
|
it { page.should have_content I18n.t("iugu.social_account") }
|
13
13
|
|
14
|
+
context "when enable_user_cancel == true" do
|
15
|
+
before(:each) do
|
16
|
+
IuguSDK::enable_user_cancel = true
|
17
|
+
visit profile_settings_path
|
18
|
+
end
|
19
|
+
|
20
|
+
it { page.should have_link I18n.t("iugu.remove_user") }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when enable_user_cancel == false" do
|
24
|
+
before(:each) do
|
25
|
+
IuguSDK::enable_user_cancel = false
|
26
|
+
visit profile_settings_path
|
27
|
+
end
|
28
|
+
it { page.should_not have_link I18n.t("iugu.remove_user") }
|
29
|
+
end
|
30
|
+
|
14
31
|
context "when user is being destroyed" do
|
15
32
|
before(:each) do
|
16
33
|
click_on I18n.t("iugu.remove_user")
|