iugusdk 1.0.0.alpha.1 → 1.0.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/iugu/account_controller.rb +24 -28
- data/app/controllers/iugu/account_domains_controller.rb +35 -5
- data/app/controllers/iugu/account_roles_controller.rb +2 -5
- data/app/controllers/iugu/account_users_controller.rb +6 -12
- data/app/controllers/iugu/confirmations_controller.rb +1 -0
- data/app/controllers/iugu/invitations_controller.rb +17 -23
- data/app/controllers/iugu/omniauth_callbacks_controller.rb +3 -1
- data/app/controllers/iugu/passwords_controller.rb +1 -0
- data/app/controllers/iugu/registrations_controller.rb +11 -0
- data/app/controllers/iugu/sessions_controller.rb +1 -0
- data/app/controllers/iugu/settings_controller.rb +14 -0
- data/app/mailers/iugu_mailer.rb +2 -2
- data/app/models/account.rb +15 -0
- data/app/models/account_domain.rb +25 -2
- data/app/models/user.rb +19 -3
- data/app/models/user_invitation.rb +15 -2
- data/app/views/iugu/account_domains/index.html.haml +50 -25
- data/app/views/iugu/account_domains/instructions.html.haml +3 -0
- data/app/views/iugu/account_users/index.html.haml +4 -2
- data/app/views/iugu/invitations/new.html.haml +19 -5
- data/app/views/iugu/registrations/new.html.haml +4 -1
- data/app/views/iugu/sessions/new.html.haml +9 -8
- data/app/views/iugu/settings/account.html.haml +31 -23
- data/app/views/iugu/settings/accounts.html.haml +5 -3
- data/app/views/iugu/settings/profile.html.haml +47 -44
- data/app/views/iugu/shared/_links.haml +14 -11
- data/app/views/layouts/settings.html.haml +1 -1
- data/config/initializers/devise.rb +0 -13
- data/config/locales/iugu.en.yml +6 -0
- data/config/locales/iugu.pt-BR.yml +6 -0
- data/config/routes.rb +9 -4
- data/db/migrate/20120725170859_add_api_token_to_account.rb +9 -0
- data/db/migrate/20120803172545_add_guest_to_users.rb +9 -0
- data/lib/iugusdk/controllers/helpers.rb +1 -1
- data/lib/iugusdk/engine.rb +1 -1
- data/lib/iugusdk/iugusdk_base_controller.rb +17 -0
- data/lib/iugusdk/version.rb +1 -1
- data/lib/iugusdk.rb +30 -5
- data/spec/controller_macros.rb +1 -1
- data/spec/controllers/account_controller_spec.rb +26 -45
- data/spec/controllers/account_domains_controller_spec.rb +87 -5
- data/spec/controllers/account_roles_controller_spec.rb +0 -14
- data/spec/controllers/invitations_controller_spec.rb +21 -1
- data/spec/controllers/registration_controller_spec.rb +15 -0
- data/spec/controllers/settings_controller_spec.rb +105 -0
- data/spec/dummy/db/schema.rb +3 -1
- data/spec/dummy/log/development.log +1579 -0
- data/spec/dummy/tmp/cache/assets/C91/3F0/sprockets%2Fcd844928d19e586b4146833b720e7d29 +0 -0
- data/spec/dummy/tmp/cache/assets/CAA/190/sprockets%2Fee7298fdc707d359368983e09687c627 +0 -0
- data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/CE6/A00/sprockets%2F583256e44957e430e1eca9ba1739b6b6 +0 -0
- data/spec/dummy/tmp/cache/assets/CE7/4B0/sprockets%2Fd3774b9099289a36db44caec70813a19 +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/CFB/F30/sprockets%2F84131db318a2faf415628c1075c32bdd +0 -0
- data/spec/dummy/tmp/cache/assets/D1A/F20/sprockets%2F102cc77ec78847746b1c164edcb9b639 +0 -0
- data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/D3A/D70/sprockets%2Fa3bc2dd9e66062ea36222fc6154827ee +0 -0
- data/spec/dummy/tmp/cache/assets/D46/E20/sprockets%2F1de16fe0c12f9988664ed66a835a6ab0 +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/D64/F60/sprockets%2F4755d7f5deef0f3212cb7ae30172a33e +0 -0
- data/spec/dummy/tmp/cache/assets/D69/850/sprockets%2F5c160a5a6d1068a17af57ab38affd379 +0 -0
- data/spec/dummy/tmp/cache/assets/D77/1A0/sprockets%2Ff3864fc006a0674b4c977ff5ca5c7d2e +0 -0
- data/spec/dummy/tmp/cache/assets/D77/920/sprockets%2Faf0e746c541e6cf4540db92c87da579c +0 -0
- data/spec/dummy/tmp/cache/assets/D7A/850/sprockets%2Fd1e5bf9f64829d062ed7314af28a4e7e +0 -0
- data/spec/dummy/tmp/cache/assets/D86/3F0/sprockets%2F8f648e11dfcec044b2997b98f619cfa6 +0 -0
- data/spec/dummy/tmp/cache/assets/DA5/130/sprockets%2F7d741fa9ebe86e96fb2bd116ca91234e +0 -0
- data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/DF2/910/sprockets%2F02db4a9e6f91b47261fa5b0eece2ab8b +0 -0
- data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/E25/5A0/sprockets%2F795f5759cf9bc7cde9f8acf8c0ca479f +0 -0
- data/spec/dummy/tmp/cache/assets/E35/0E0/sprockets%2F9f57eaeefd4c9d5efb41c9801e3f1c1a +0 -0
- data/spec/dummy/tmp/cache/sass/e5be18dde92936a4632e65289dad5788ed73dd60/settings.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/default.sassc +0 -0
- data/spec/fabricators/account_domain_fabricator.rb +5 -1
- data/spec/models/account_domain_spec.rb +49 -12
- data/spec/models/account_spec.rb +32 -4
- data/spec/models/user_invitation_spec.rb +23 -1
- data/spec/models/user_spec.rb +76 -0
- data/spec/requests/account_domain_spec.rb +71 -37
- data/spec/requests/account_roles_spec.rb +1 -0
- data/spec/requests/account_spec.rb +65 -3
- data/spec/requests/account_users_spec.rb +1 -0
- data/spec/requests/omniauth_spec.rb +34 -0
- data/spec/requests/settings_spec.rb +4 -4
- data/spec/requests/user_invitation_spec.rb +32 -1
- data/spec/requests/user_spec.rb +13 -0
- metadata +126 -70
- data/lib/iugusdk/locale_filter.rb +0 -12
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
|
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
|
@@ -10,15 +10,24 @@ describe AccountDomain do
|
|
10
10
|
it { should validate_presence_of(:account_id) }
|
11
11
|
|
12
12
|
it 'should accept url with correct pattern' do
|
13
|
-
@
|
14
|
-
|
15
|
-
|
13
|
+
@account = Fabricate(:account)
|
14
|
+
@domain = AccountDomain.create(:url => 'valid.url.test', :account => @account)
|
15
|
+
@domain.valid?.should be_true
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'should not accept url with incorrect pattern' do
|
19
|
-
Fabricate
|
19
|
+
@account = Fabricate(:account)
|
20
|
+
@account.account_domains << @domain = Fabricate.build(:account_domain) do
|
20
21
|
url 'http://www.t3st.net'
|
21
|
-
end
|
22
|
+
end
|
23
|
+
@domain.valid?.should be_false
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not accept repeated domain' do
|
27
|
+
@account = Fabricate(:account)
|
28
|
+
@account.account_domains << @domain1 = AccountDomain.create(:url => 'valid.url.test')
|
29
|
+
@account.account_domains << @domain2 = AccountDomain.create(:url => 'valid.url.test')
|
30
|
+
@domain2.new_record?.should be_true
|
22
31
|
end
|
23
32
|
|
24
33
|
it 'should not accept url in the blacklist' do
|
@@ -37,6 +46,16 @@ describe AccountDomain do
|
|
37
46
|
end
|
38
47
|
end
|
39
48
|
|
49
|
+
it 'should set the first verified domain as primary if the primary domain is destroyed' do
|
50
|
+
@account = Fabricate(:account)
|
51
|
+
@account.account_domains << @domain1 = AccountDomain.create(:url => "url1.test.test", :verified => true)
|
52
|
+
@account.account_domains << @domain2 = AccountDomain.create(:url => "url2.test.test", :verified => true)
|
53
|
+
@domain1.set_primary
|
54
|
+
@domain1.destroy
|
55
|
+
@domain2.reload
|
56
|
+
@domain2.primary.should be_true
|
57
|
+
end
|
58
|
+
|
40
59
|
context "calculate_token" do
|
41
60
|
it 'should return url token' do
|
42
61
|
@account_domain = Fabricate(:account_domain) do
|
@@ -77,7 +96,15 @@ describe AccountDomain do
|
|
77
96
|
@account_domain1.reload
|
78
97
|
@account_domain1.verified.should be_false
|
79
98
|
end
|
80
|
-
|
99
|
+
|
100
|
+
it 'should set primary as true if its the first domain of the account' do
|
101
|
+
@account = Fabricate(:account)
|
102
|
+
@account.account_domains << @domain = Fabricate(:account_domain) { url 'www.test.net' }
|
103
|
+
@domain.verify
|
104
|
+
@domain.reload
|
105
|
+
@domain.primary.should be_true
|
106
|
+
end
|
107
|
+
|
81
108
|
end
|
82
109
|
|
83
110
|
context "set_primary" do
|
@@ -86,23 +113,33 @@ describe AccountDomain do
|
|
86
113
|
@account.account_domains << @domain1 = Fabricate(:account_domain) do
|
87
114
|
url "www.url1.net"
|
88
115
|
verified true
|
89
|
-
primary
|
116
|
+
primary true
|
90
117
|
end
|
91
118
|
@account.account_domains << @domain2 = Fabricate(:account_domain) do
|
92
119
|
url "www.url2.net"
|
93
120
|
verified true
|
94
|
-
primary
|
121
|
+
primary false
|
95
122
|
end
|
123
|
+
@domain1.account = @account
|
124
|
+
@domain2.account = @account
|
125
|
+
@domain1.save
|
126
|
+
@domain2.save
|
96
127
|
end
|
97
128
|
|
98
129
|
it 'should make domain primary' do
|
99
|
-
@
|
100
|
-
@
|
130
|
+
@domain2.set_primary
|
131
|
+
@domain2.primary.should be_true
|
101
132
|
end
|
102
133
|
|
103
134
|
it 'should make other account domains not primary' do
|
104
|
-
@
|
105
|
-
@
|
135
|
+
@domain2.set_primary
|
136
|
+
@domain1.reload
|
137
|
+
@domain1.primary.should be_false
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should not make domain primary if its not verified' do
|
141
|
+
@domain2.update_attribute(:verified, false)
|
142
|
+
@domain2.set_primary
|
106
143
|
@domain2.primary.should be_false
|
107
144
|
end
|
108
145
|
|
data/spec/models/account_spec.rb
CHANGED
@@ -9,6 +9,7 @@ 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) }
|
12
13
|
|
13
14
|
it "should return true for a valid user of account" do
|
14
15
|
@user = Fabricate(:user, :email => "me@me.com")
|
@@ -22,6 +23,11 @@ describe Account do
|
|
22
23
|
@account = Fabricate.build(:account) { subdomain "subdominio" }.should_not be_valid
|
23
24
|
end
|
24
25
|
|
26
|
+
it 'should set api_token before create' do
|
27
|
+
@account = Fabricate(:account)
|
28
|
+
@account.api_token.should_not be_nil
|
29
|
+
end
|
30
|
+
|
25
31
|
context "destruction_job method" do
|
26
32
|
before(:each) do
|
27
33
|
@account = Fabricate(:account)
|
@@ -132,10 +138,7 @@ describe Account do
|
|
132
138
|
@account = Fabricate(:account) do
|
133
139
|
subdomain "subdomainfind"
|
134
140
|
end
|
135
|
-
@account.account_domains <<
|
136
|
-
url "getfromdomain.account.test"
|
137
|
-
verified true
|
138
|
-
end
|
141
|
+
@account.account_domains << AccountDomain.create(:url => "getfromdomain.account.test", :verified => true)
|
139
142
|
end
|
140
143
|
|
141
144
|
it 'should return the account which owns the domain' do
|
@@ -150,6 +153,31 @@ describe Account do
|
|
150
153
|
Account.get_from_domain("notused.domain.test").should be_nil
|
151
154
|
end
|
152
155
|
end
|
156
|
+
|
157
|
+
context "generate_api_token" do
|
158
|
+
before(:each) do
|
159
|
+
@account = Fabricate(:account)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'should return a new token' do
|
163
|
+
old_token = @account.api_token
|
164
|
+
@account.send(:generate_api_token).should_not == old_token
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
context "update_api_token" do
|
170
|
+
before(:each) do
|
171
|
+
@account = Fabricate(:account)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'should replace api_token' do
|
175
|
+
old_token = @account.api_token
|
176
|
+
@account.update_api_token
|
177
|
+
@account.api_token.should_not == old_token
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
153
181
|
|
154
182
|
|
155
183
|
end
|
@@ -4,7 +4,15 @@ describe UserInvitation do
|
|
4
4
|
|
5
5
|
it { should belong_to :account }
|
6
6
|
|
7
|
-
|
7
|
+
it 'should not accept an email already used by an account user' do
|
8
|
+
@account = Fabricate(:account)
|
9
|
+
@user = Fabricate(:user, :email => "invited@test.test")
|
10
|
+
@account.users << @user
|
11
|
+
@user_invitation = UserInvitation.new(:email => "invited@test.test", :account_id => @account.id)
|
12
|
+
@user_invitation.should_not be_valid
|
13
|
+
end
|
14
|
+
|
15
|
+
context "before save" do
|
8
16
|
|
9
17
|
context "if has no token" do
|
10
18
|
it 'should generate one' do
|
@@ -81,6 +89,20 @@ describe UserInvitation do
|
|
81
89
|
@user_invitation.accept(@user)
|
82
90
|
AccountUser.last.is?('user').should be_true
|
83
91
|
end
|
92
|
+
|
93
|
+
it 'should return true if successfull' do
|
94
|
+
@user_invitation.account = @account
|
95
|
+
@user_invitation.save
|
96
|
+
@user_invitation.accept(@user).should be_true
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should return false if user is already member of the account' do
|
100
|
+
@user_invitation.account = @account
|
101
|
+
@user_invitation.save
|
102
|
+
@account.users << @user
|
103
|
+
@user_invitation.accept(@user).should be_false
|
104
|
+
end
|
105
|
+
|
84
106
|
end
|
85
107
|
end
|
86
108
|
|
data/spec/models/user_spec.rb
CHANGED
@@ -7,6 +7,63 @@ describe User do
|
|
7
7
|
it { should have_many(:account_users) }
|
8
8
|
it { should have_many(:accounts).through(:account_users) }
|
9
9
|
it { should have_many(:social_accounts) }
|
10
|
+
it { should validate_presence_of(:email) }
|
11
|
+
|
12
|
+
it 'should not require email if guest == true' do
|
13
|
+
user = Fabricate.build(:user) do
|
14
|
+
email nil
|
15
|
+
guest true
|
16
|
+
end.should be_valid
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when enable_user_confirmation == false" do
|
20
|
+
before(:each) do
|
21
|
+
IuguSDK::enable_user_confirmation = false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should skip confirmation' do
|
25
|
+
@user = User.create(:email => "confirmation@skip.test", :password => "testtest", :password_confirmation => "testtest")
|
26
|
+
@user.confirmed?.should be_true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when enable_user_confirmation == true" do
|
31
|
+
before(:each) do
|
32
|
+
IuguSDK::enable_user_confirmation = true
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should not skip confirmation' do
|
36
|
+
@user = User.create(:email => "confirmation@needed.test", :password => "testtest", :password_confirmation => "testtest")
|
37
|
+
@user.confirmed?.should be_false
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when enable_email_reconfirmation == true" do
|
43
|
+
before(:each) do
|
44
|
+
IuguSDK::enable_email_reconfirmation = true
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should not skip email reconfirmation' do
|
48
|
+
@user = User.create(:email => "reconfirmation@needed.test", :password => "testtest", :password_confirmation => "testtest")
|
49
|
+
@user.email = "new@email.test"
|
50
|
+
@user.save
|
51
|
+
@user.email.should == "reconfirmation@needed.test"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when enable_email_reconfirmation == false" do
|
56
|
+
before(:each) do
|
57
|
+
IuguSDK::enable_email_reconfirmation = false
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should skip email reconfirmation' do
|
61
|
+
@user = User.create(:email => "reconfirmation@needed.test", :password => "testtest", :password_confirmation => "testtest")
|
62
|
+
@user.email = "new@email.test"
|
63
|
+
@user.save
|
64
|
+
@user.email.should == "new@email.test"
|
65
|
+
end
|
66
|
+
end
|
10
67
|
|
11
68
|
context "create_social" do
|
12
69
|
before do
|
@@ -183,5 +240,24 @@ describe User do
|
|
183
240
|
|
184
241
|
end
|
185
242
|
|
243
|
+
context "create_guest method" do
|
244
|
+
before(:each) do
|
245
|
+
@user = User.create_guest("pt-BR")
|
246
|
+
end
|
247
|
+
|
248
|
+
it { @user.class.should == User }
|
249
|
+
|
250
|
+
it { @user.email.should be_blank }
|
251
|
+
|
252
|
+
it { @user.guest.should be_true }
|
253
|
+
|
254
|
+
it { @user.name.should == "Guest" }
|
255
|
+
|
256
|
+
it { @user.locale.should == "pt-BR" }
|
257
|
+
|
258
|
+
it { @user.confirmed?.should be_true }
|
259
|
+
|
260
|
+
end
|
261
|
+
|
186
262
|
|
187
263
|
end
|
@@ -3,72 +3,106 @@ require 'spec_helper'
|
|
3
3
|
describe "Account Domains requests" do
|
4
4
|
context "index view" do
|
5
5
|
before(:each) do
|
6
|
+
IuguSDK::enable_social_login = true
|
6
7
|
visit "/account/auth/facebook"
|
7
8
|
@user = User.last
|
8
9
|
@account = Account.last
|
9
|
-
@account.account_domains << @domain =
|
10
|
+
@account.account_domains << @domain = AccountDomain.create( url: "index.test.net" )
|
10
11
|
end
|
11
12
|
|
12
|
-
context "when
|
13
|
+
context "when enable_subdomain == true" do
|
13
14
|
before(:each) do
|
14
|
-
|
15
|
+
IuguSDK::enable_subdomain = true
|
15
16
|
visit account_domains_index_path(@account.id)
|
16
17
|
end
|
17
18
|
|
18
|
-
it { page.should
|
19
|
-
|
19
|
+
it { page.should have_field 'account[subdomain]' }
|
20
|
+
|
20
21
|
end
|
21
|
-
|
22
|
-
context "when
|
22
|
+
|
23
|
+
context "when enable_subdomain == false" do
|
23
24
|
before(:each) do
|
24
|
-
|
25
|
+
IuguSDK::enable_custom_domain = true
|
26
|
+
IuguSDK::enable_subdomain = false
|
25
27
|
visit account_domains_index_path(@account.id)
|
26
28
|
end
|
27
29
|
|
28
|
-
it { page.
|
29
|
-
|
30
|
-
end
|
30
|
+
it { page.should_not have_field 'account[subdomain]' }
|
31
31
|
|
32
|
-
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when enable_custom_domain == true" do
|
33
35
|
before(:each) do
|
34
|
-
|
35
|
-
visit account_domains_index_path(@account.id)
|
36
|
+
IuguSDK::enable_custom_domain = true
|
36
37
|
end
|
37
|
-
|
38
|
-
it { page.should have_content I18n.t("iugu.verified") }
|
39
38
|
|
40
|
-
|
39
|
+
context "and domain is primary" do
|
40
|
+
before(:each) do
|
41
|
+
@domain.update_attribute(:primary, true)
|
42
|
+
visit account_domains_index_path(@account.id)
|
43
|
+
end
|
44
|
+
|
45
|
+
it { page.should have_content I18n.t("iugu.primary") }
|
41
46
|
|
42
|
-
context "when domain is not verified" do
|
43
|
-
before(:each) do
|
44
|
-
@domain.update_attribute(:verified, false)
|
45
|
-
visit account_domains_index_path(@account.id)
|
46
47
|
end
|
48
|
+
|
49
|
+
context "and domain is not primary" do
|
50
|
+
before(:each) do
|
51
|
+
@domain.update_attribute(:primary, false)
|
52
|
+
end
|
53
|
+
|
54
|
+
context "and domain is verified" do
|
55
|
+
before(:each) do
|
56
|
+
@domain.update_attribute(:verified, true)
|
57
|
+
visit account_domains_index_path(@account.id)
|
58
|
+
end
|
59
|
+
|
60
|
+
it { page.should have_link I18n.t("iugu.set_primary") }
|
61
|
+
|
62
|
+
end
|
47
63
|
|
48
|
-
|
64
|
+
context "and domain is not verified" do
|
65
|
+
before(:each) do
|
66
|
+
@domain.update_attribute(:verified, false)
|
67
|
+
visit account_domains_index_path(@account.id)
|
68
|
+
end
|
49
69
|
|
50
|
-
|
70
|
+
it { page.should_not have_link I18n.t("iugu.set_primary") }
|
71
|
+
|
72
|
+
end
|
51
73
|
|
52
|
-
context "when current_user is the owner of the account" do
|
53
|
-
before(:each) do
|
54
|
-
@account_user = AccountUser.find_by_user_id_and_account_id(@user.id, @account.id)
|
55
|
-
@account_user.set_roles ["owner"]
|
56
|
-
visit account_domains_index_path(@account.id)
|
57
74
|
end
|
75
|
+
|
76
|
+
context "and domain is verified" do
|
77
|
+
before(:each) do
|
78
|
+
@domain.update_attribute(:verified, true)
|
79
|
+
visit account_domains_index_path(@account.id)
|
80
|
+
end
|
81
|
+
|
82
|
+
it { page.should have_content I18n.t("iugu.verified") }
|
58
83
|
|
59
|
-
|
84
|
+
end
|
85
|
+
|
86
|
+
context "and domain is not verified" do
|
87
|
+
before(:each) do
|
88
|
+
@domain.update_attribute(:verified, false)
|
89
|
+
visit account_domains_index_path(@account.id)
|
90
|
+
end
|
60
91
|
|
61
|
-
|
92
|
+
it { page.should have_link I18n.t("iugu.not_verified") }
|
62
93
|
|
63
|
-
context "when current_user is not the owner of the account" do
|
64
|
-
before(:each) do
|
65
|
-
@account.account_users << Fabricate(:account_user) { user Fabricate(:user) { email "notowner@account.test" } }
|
66
|
-
@account_user = AccountUser.find_by_user_id_and_account_id(@user.id, @account.id)
|
67
|
-
@account_user.set_roles ["user"]
|
68
|
-
visit account_domains_index_path(@account.id)
|
69
94
|
end
|
70
95
|
|
71
|
-
|
96
|
+
context "and current_user is the owner of the account" do
|
97
|
+
before(:each) do
|
98
|
+
@account_user = AccountUser.find_by_user_id_and_account_id(@user.id, @account.id)
|
99
|
+
@account_user.set_roles ["owner"]
|
100
|
+
visit account_domains_index_path(@account.id)
|
101
|
+
end
|
102
|
+
|
103
|
+
it { page.should have_link I18n.t("iugu.remove") }
|
104
|
+
|
105
|
+
end
|
72
106
|
|
73
107
|
end
|
74
108
|
|
@@ -2,6 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'accounts settings view' do
|
4
4
|
before(:each) do
|
5
|
+
IuguSDK::enable_social_login = true
|
5
6
|
visit '/account/auth/facebook'
|
6
7
|
visit account_settings_path
|
7
8
|
@user = User.last
|
@@ -10,11 +11,24 @@ describe 'accounts settings view' do
|
|
10
11
|
|
11
12
|
it { page.should have_link I18n.t("iugu.settings") }
|
12
13
|
|
13
|
-
context "when
|
14
|
+
context "when enable_multiple_accounts == true" do
|
14
15
|
before(:each) do
|
15
|
-
IuguSDK::
|
16
|
+
IuguSDK::enable_multiple_accounts = true
|
17
|
+
visit account_settings_path
|
16
18
|
end
|
17
19
|
|
20
|
+
it { page.should have_link I18n.t("iugu.create_account") }
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when enable_multiple_accounts == false" do
|
25
|
+
before(:each) do
|
26
|
+
IuguSDK::enable_multiple_accounts = false
|
27
|
+
visit account_settings_path
|
28
|
+
end
|
29
|
+
|
30
|
+
it { page.should_not have_link I18n.t("iugu.create_account") }
|
31
|
+
|
18
32
|
context "and user has only one account" do
|
19
33
|
before(:each) do
|
20
34
|
@user = User.last
|
@@ -47,16 +61,35 @@ describe 'accounts settings view' do
|
|
47
61
|
@user = User.last
|
48
62
|
@user.accounts << @target_account = Fabricate(:account)
|
49
63
|
@account_user = AccountUser.last
|
64
|
+
IuguSDK::enable_custom_domain = true
|
65
|
+
IuguSDK::enable_subdomain = true
|
66
|
+
end
|
67
|
+
|
68
|
+
context "when current_user admin the account" do
|
69
|
+
before(:each) do
|
70
|
+
@account_user.set_roles ["admin"]
|
71
|
+
visit account_view_path(@target_account.id)
|
72
|
+
end
|
73
|
+
|
74
|
+
it { page.should have_link I18n.t("iugu.manage") }
|
75
|
+
|
50
76
|
end
|
51
77
|
|
52
78
|
context "when current_user owns the account" do
|
53
79
|
before(:each) do
|
54
|
-
|
80
|
+
@account_user.set_roles ["owner"]
|
55
81
|
visit account_view_path(@target_account.id)
|
56
82
|
end
|
83
|
+
it { page.should have_link I18n.t("iugu.manage") }
|
57
84
|
|
58
85
|
it { page.should have_link I18n.t("iugu.cancel_account") }
|
86
|
+
|
87
|
+
it { page.should have_content @target_account.api_token }
|
59
88
|
|
89
|
+
it { page.should have_link I18n.t("iugu.generate_new_token") }
|
90
|
+
|
91
|
+
it { page.should have_field 'account[name]' }
|
92
|
+
|
60
93
|
context "when account is being canceled" do
|
61
94
|
context "if delay_account_exclusion == 0" do
|
62
95
|
before(:each) do
|
@@ -88,8 +121,37 @@ describe 'accounts settings view' do
|
|
88
121
|
visit account_view_path(@target_account.id)
|
89
122
|
end
|
90
123
|
|
124
|
+
it { page.should_not have_field 'account[name]' }
|
125
|
+
|
126
|
+
it { page.should_not have_link I18n.t("iugu.manage") }
|
127
|
+
|
91
128
|
it { page.should_not have_link I18n.t("iugu.cancel_account") }
|
92
129
|
|
130
|
+
it { page.should_not have_content @target_account.api_token }
|
131
|
+
|
132
|
+
it { page.should_not have_link I18n.t("iugu.generate_new_token") }
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
context "when enable_custom_domain == false && enable_subdomain == false" do
|
137
|
+
before(:each) do
|
138
|
+
IuguSDK::enable_custom_domain = false
|
139
|
+
IuguSDK::enable_subdomain = false
|
140
|
+
visit account_view_path(@target_account.id)
|
141
|
+
end
|
142
|
+
|
143
|
+
it { page.should_not have_link I18n.t("iugu.manage") }
|
144
|
+
|
145
|
+
end
|
146
|
+
|
147
|
+
context "when enable_account_api_token == false" do
|
148
|
+
before(:each) do
|
149
|
+
IuguSDK::enable_account_api_token = false
|
150
|
+
visit account_view_path(@target_account.id)
|
151
|
+
end
|
152
|
+
|
153
|
+
it { page.should_not have_link I18n.t("iugu.generate_new_token") }
|
154
|
+
|
93
155
|
end
|
94
156
|
|
95
157
|
|