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.
Files changed (90) hide show
  1. data/app/controllers/iugu/account_controller.rb +24 -28
  2. data/app/controllers/iugu/account_domains_controller.rb +35 -5
  3. data/app/controllers/iugu/account_roles_controller.rb +2 -5
  4. data/app/controllers/iugu/account_users_controller.rb +6 -12
  5. data/app/controllers/iugu/confirmations_controller.rb +1 -0
  6. data/app/controllers/iugu/invitations_controller.rb +17 -23
  7. data/app/controllers/iugu/omniauth_callbacks_controller.rb +3 -1
  8. data/app/controllers/iugu/passwords_controller.rb +1 -0
  9. data/app/controllers/iugu/registrations_controller.rb +11 -0
  10. data/app/controllers/iugu/sessions_controller.rb +1 -0
  11. data/app/controllers/iugu/settings_controller.rb +14 -0
  12. data/app/mailers/iugu_mailer.rb +2 -2
  13. data/app/models/account.rb +15 -0
  14. data/app/models/account_domain.rb +25 -2
  15. data/app/models/user.rb +19 -3
  16. data/app/models/user_invitation.rb +15 -2
  17. data/app/views/iugu/account_domains/index.html.haml +50 -25
  18. data/app/views/iugu/account_domains/instructions.html.haml +3 -0
  19. data/app/views/iugu/account_users/index.html.haml +4 -2
  20. data/app/views/iugu/invitations/new.html.haml +19 -5
  21. data/app/views/iugu/registrations/new.html.haml +4 -1
  22. data/app/views/iugu/sessions/new.html.haml +9 -8
  23. data/app/views/iugu/settings/account.html.haml +31 -23
  24. data/app/views/iugu/settings/accounts.html.haml +5 -3
  25. data/app/views/iugu/settings/profile.html.haml +47 -44
  26. data/app/views/iugu/shared/_links.haml +14 -11
  27. data/app/views/layouts/settings.html.haml +1 -1
  28. data/config/initializers/devise.rb +0 -13
  29. data/config/locales/iugu.en.yml +6 -0
  30. data/config/locales/iugu.pt-BR.yml +6 -0
  31. data/config/routes.rb +9 -4
  32. data/db/migrate/20120725170859_add_api_token_to_account.rb +9 -0
  33. data/db/migrate/20120803172545_add_guest_to_users.rb +9 -0
  34. data/lib/iugusdk/controllers/helpers.rb +1 -1
  35. data/lib/iugusdk/engine.rb +1 -1
  36. data/lib/iugusdk/iugusdk_base_controller.rb +17 -0
  37. data/lib/iugusdk/version.rb +1 -1
  38. data/lib/iugusdk.rb +30 -5
  39. data/spec/controller_macros.rb +1 -1
  40. data/spec/controllers/account_controller_spec.rb +26 -45
  41. data/spec/controllers/account_domains_controller_spec.rb +87 -5
  42. data/spec/controllers/account_roles_controller_spec.rb +0 -14
  43. data/spec/controllers/invitations_controller_spec.rb +21 -1
  44. data/spec/controllers/registration_controller_spec.rb +15 -0
  45. data/spec/controllers/settings_controller_spec.rb +105 -0
  46. data/spec/dummy/db/schema.rb +3 -1
  47. data/spec/dummy/log/development.log +1579 -0
  48. data/spec/dummy/tmp/cache/assets/C91/3F0/sprockets%2Fcd844928d19e586b4146833b720e7d29 +0 -0
  49. data/spec/dummy/tmp/cache/assets/CAA/190/sprockets%2Fee7298fdc707d359368983e09687c627 +0 -0
  50. data/spec/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
  51. data/spec/dummy/tmp/cache/assets/CE6/A00/sprockets%2F583256e44957e430e1eca9ba1739b6b6 +0 -0
  52. data/spec/dummy/tmp/cache/assets/CE7/4B0/sprockets%2Fd3774b9099289a36db44caec70813a19 +0 -0
  53. data/spec/dummy/tmp/cache/assets/CF1/A70/sprockets%2F368a631d9662bcc4891c91f739b7be37 +0 -0
  54. data/spec/dummy/tmp/cache/assets/CF6/A50/sprockets%2Ff434c1ed5d55916f790cf698832f76b1 +0 -0
  55. data/spec/dummy/tmp/cache/assets/CFB/F30/sprockets%2F84131db318a2faf415628c1075c32bdd +0 -0
  56. data/spec/dummy/tmp/cache/assets/D1A/F20/sprockets%2F102cc77ec78847746b1c164edcb9b639 +0 -0
  57. data/spec/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  58. data/spec/dummy/tmp/cache/assets/D3A/D70/sprockets%2Fa3bc2dd9e66062ea36222fc6154827ee +0 -0
  59. data/spec/dummy/tmp/cache/assets/D46/E20/sprockets%2F1de16fe0c12f9988664ed66a835a6ab0 +0 -0
  60. data/spec/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
  61. data/spec/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
  62. data/spec/dummy/tmp/cache/assets/D64/F60/sprockets%2F4755d7f5deef0f3212cb7ae30172a33e +0 -0
  63. data/spec/dummy/tmp/cache/assets/D69/850/sprockets%2F5c160a5a6d1068a17af57ab38affd379 +0 -0
  64. data/spec/dummy/tmp/cache/assets/D77/1A0/sprockets%2Ff3864fc006a0674b4c977ff5ca5c7d2e +0 -0
  65. data/spec/dummy/tmp/cache/assets/D77/920/sprockets%2Faf0e746c541e6cf4540db92c87da579c +0 -0
  66. data/spec/dummy/tmp/cache/assets/D7A/850/sprockets%2Fd1e5bf9f64829d062ed7314af28a4e7e +0 -0
  67. data/spec/dummy/tmp/cache/assets/D86/3F0/sprockets%2F8f648e11dfcec044b2997b98f619cfa6 +0 -0
  68. data/spec/dummy/tmp/cache/assets/DA5/130/sprockets%2F7d741fa9ebe86e96fb2bd116ca91234e +0 -0
  69. data/spec/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
  70. data/spec/dummy/tmp/cache/assets/DF2/910/sprockets%2F02db4a9e6f91b47261fa5b0eece2ab8b +0 -0
  71. data/spec/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  72. data/spec/dummy/tmp/cache/assets/E25/5A0/sprockets%2F795f5759cf9bc7cde9f8acf8c0ca479f +0 -0
  73. data/spec/dummy/tmp/cache/assets/E35/0E0/sprockets%2F9f57eaeefd4c9d5efb41c9801e3f1c1a +0 -0
  74. data/spec/dummy/tmp/cache/sass/e5be18dde92936a4632e65289dad5788ed73dd60/settings.sassc +0 -0
  75. data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/default.sassc +0 -0
  76. data/spec/fabricators/account_domain_fabricator.rb +5 -1
  77. data/spec/models/account_domain_spec.rb +49 -12
  78. data/spec/models/account_spec.rb +32 -4
  79. data/spec/models/user_invitation_spec.rb +23 -1
  80. data/spec/models/user_spec.rb +76 -0
  81. data/spec/requests/account_domain_spec.rb +71 -37
  82. data/spec/requests/account_roles_spec.rb +1 -0
  83. data/spec/requests/account_spec.rb +65 -3
  84. data/spec/requests/account_users_spec.rb +1 -0
  85. data/spec/requests/omniauth_spec.rb +34 -0
  86. data/spec/requests/settings_spec.rb +4 -4
  87. data/spec/requests/user_invitation_spec.rb +32 -1
  88. data/spec/requests/user_spec.rb +13 -0
  89. metadata +126 -70
  90. data/lib/iugusdk/locale_filter.rb +0 -12
@@ -1,6 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'omniauth requests' do
4
+ before(:each) do
5
+ IuguSDK::enable_social_login = true
6
+ IuguSDK::enable_social_linking = true
7
+ end
4
8
  context "provider not found" do
5
9
  before(:each) do
6
10
  visit '/account/auth/orkut'
@@ -10,6 +14,35 @@ describe 'omniauth requests' do
10
14
 
11
15
  end
12
16
 
17
+ context "when not signed in" do
18
+ context "and enable_social_login == false" do
19
+ before(:each) do
20
+ IuguSDK::enable_social_login = false
21
+ end
22
+
23
+ it 'should raise RoutingError' do
24
+ lambda {
25
+ visit '/account/auth/facebook'
26
+ }.should raise_error ActionController::RoutingError
27
+ end
28
+ end
29
+ end
30
+
31
+ context "when signed in" do
32
+ context "and enable_social_linking == false" do
33
+ before(:each) do
34
+ IuguSDK::enable_social_linking = false
35
+ visit '/account/auth/facebook'
36
+ end
37
+
38
+ it 'should raise RoutingError' do
39
+ lambda {
40
+ visit '/account/auth/facebook'
41
+ }.should raise_error ActionController::RoutingError
42
+ end
43
+ end
44
+ end
45
+
13
46
  context "facebook" do
14
47
  context 'not signed in' do
15
48
  before(:each) do
@@ -17,6 +50,7 @@ describe 'omniauth requests' do
17
50
  end
18
51
 
19
52
  it { page.should have_content "signed in" }
53
+
20
54
  end
21
55
 
22
56
  context "already signed in" do
@@ -6,9 +6,9 @@ describe "Settings requests" do
6
6
  visit '/account/auth/facebook'
7
7
  end
8
8
 
9
- context "when allow_create_accounts == false" do
9
+ context "when enable_multiple_accounts == false" do
10
10
  before(:each) do
11
- IuguSDK::allow_create_account = false
11
+ IuguSDK::enable_multiple_accounts = false
12
12
  end
13
13
 
14
14
  context "when user has only 1 account" do
@@ -37,9 +37,9 @@ describe "Settings requests" do
37
37
  end
38
38
 
39
39
 
40
- context "when allow_create_accounts == true" do
40
+ context "when enable_multiple_accounts == true" do
41
41
  before(:each) do
42
- IuguSDK::allow_create_account = true
42
+ IuguSDK::enable_multiple_accounts = true
43
43
  visit settings_path
44
44
  end
45
45
 
@@ -26,7 +26,8 @@ describe 'UserInvitations requests' do
26
26
  visit'/account/auth/facebook'
27
27
  @user = User.last
28
28
  @account = @user.accounts.first
29
- visit new_invite_path(@account.id)
29
+ @account.users << Fabricate(:user, :email => "tester@roles.test")
30
+ visit new_invite_path(:account_id => @account.id)
30
31
  end
31
32
 
32
33
  APP_ROLES['roles'].each do |role|
@@ -36,7 +37,37 @@ describe 'UserInvitations requests' do
36
37
  it { page.should have_content 'Email' }
37
38
 
38
39
  it { page.should have_button I18n.t("iugu.invite") }
40
+
41
+ context "when current_user is owner" do
42
+ before(:each) do
43
+ @account_user = AccountUser.find_by_user_id_and_account_id(@user.id, @account.id)
44
+ @account_user.set_roles ["owner"]
45
+ visit new_invite_path(@account.id)
46
+ end
47
+
48
+ APP_ROLES['roles'].each do |role|
49
+ it { page.should have_content role }
50
+ end
51
+
52
+ end
39
53
 
54
+ context "when current_user is admin" do
55
+ before(:each) do
56
+ @account_user = AccountUser.find_by_user_id_and_account_id(@user.id, @account.id)
57
+ @account_user.set_roles ["admin"]
58
+ visit new_invite_path(@account.id)
59
+ end
60
+
61
+ APP_ROLES['roles'].each do |role|
62
+ unless role == APP_ROLES['owner_role'] || role == APP_ROLES['admin_role']
63
+ it { page.should have_content role }
64
+ else
65
+ it { page.should_not have_content role }
66
+ end
67
+ end
68
+
69
+ end
70
+
40
71
  end
41
72
 
42
73
  end
@@ -2,11 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe 'account settings view' do
4
4
  before(:each) do
5
+ IuguSDK::enable_social_login = true
6
+ IuguSDK::enable_social_linking = true
5
7
  visit '/account/auth/facebook'
6
8
  visit profile_settings_path
7
9
  end
8
10
 
9
11
  it { page.should have_link I18n.t("iugu.remove_user") }
12
+ it { page.should have_content I18n.t("iugu.social_account") }
10
13
 
11
14
  context "when user is being destroyed" do
12
15
  before(:each) do
@@ -31,4 +34,14 @@ describe 'account settings view' do
31
34
 
32
35
  end
33
36
 
37
+ context "when enable_social_linking == false" do
38
+ before(:each) do
39
+ IuguSDK::enable_social_linking = false
40
+ visit profile_settings_path
41
+ end
42
+
43
+ it { page.should_not have_content I18n.t("iugu.social_account") }
44
+
45
+ end
46
+
34
47
  end