iugusdk 1.0.0.alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +39 -0
- data/app/assets/images/application_logo.png +0 -0
- data/app/assets/javascripts/settings.js +10 -0
- data/app/assets/javascripts/settings_code.js.coffee.erb +0 -0
- data/app/assets/stylesheets/settings.sass +120 -0
- data/app/controllers/iugu/account_controller.rb +63 -0
- data/app/controllers/iugu/account_domains_controller.rb +64 -0
- data/app/controllers/iugu/account_roles_controller.rb +20 -0
- data/app/controllers/iugu/account_settings_controller.rb +17 -0
- data/app/controllers/iugu/account_users_controller.rb +43 -0
- data/app/controllers/iugu/application_domain_controller.rb +11 -0
- data/app/controllers/iugu/confirmations_controller.rb +2 -0
- data/app/controllers/iugu/invitations_controller.rb +49 -0
- data/app/controllers/iugu/omniauth_callbacks_controller.rb +23 -0
- data/app/controllers/iugu/passwords_controller.rb +2 -0
- data/app/controllers/iugu/profile_controller.rb +44 -0
- data/app/controllers/iugu/registrations_controller.rb +3 -0
- data/app/controllers/iugu/sessions_controller.rb +2 -0
- data/app/controllers/iugu/settings_controller.rb +11 -0
- data/app/controllers/iugu/unlocks_controller.rb +2 -0
- data/app/mailers/iugu_mailer.rb +16 -0
- data/app/models/account.rb +53 -0
- data/app/models/account_domain.rb +69 -0
- data/app/models/account_role.rb +24 -0
- data/app/models/account_user.rb +55 -0
- data/app/models/available_language.rb +10 -0
- data/app/models/social_account.rb +14 -0
- data/app/models/user.rb +107 -0
- data/app/models/user_invitation.rb +39 -0
- data/app/validators/email_validator.rb +17 -0
- data/app/views/iugu-old/account_settings.html.haml +17 -0
- data/app/views/iugu-old/login.html.haml +28 -0
- data/app/views/iugu-old/mails/confirmation_instructions.html.erb +5 -0
- data/app/views/iugu-old/mails/reset_password_instructions.html.erb +8 -0
- data/app/views/iugu-old/mails/unlock_instructions.html.erb +7 -0
- data/app/views/iugu-old/profile_settings.html.haml +76 -0
- data/app/views/iugu-old/signup.html.haml +36 -0
- data/app/views/iugu/account_domains/index.html.haml +33 -0
- data/app/views/iugu/account_domains/instructions.html.haml +0 -0
- data/app/views/iugu/account_roles/edit.html.haml +17 -0
- data/app/views/iugu/account_roles/update.html.haml +0 -0
- data/app/views/iugu/account_users/index.html.haml +23 -0
- data/app/views/iugu/account_users/view.html.haml +0 -0
- data/app/views/iugu/confirmations/new.html.haml +8 -0
- data/app/views/iugu/invitations/edit.html.haml +8 -0
- data/app/views/iugu/invitations/new.html.haml +13 -0
- data/app/views/iugu/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/iugu/mailer/invitation.html.haml +1 -0
- data/app/views/iugu/mailer/reset_password_instructions.html.haml +4 -0
- data/app/views/iugu/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/iugu/passwords/edit.html.haml +11 -0
- data/app/views/iugu/passwords/new.html.haml +8 -0
- data/app/views/iugu/registrations/edit.html.haml +15 -0
- data/app/views/iugu/registrations/new.html.haml +11 -0
- data/app/views/iugu/sessions/new.html.haml +9 -0
- data/app/views/iugu/settings/account.html.haml +48 -0
- data/app/views/iugu/settings/accounts.html.haml +33 -0
- data/app/views/iugu/settings/profile.html.haml +96 -0
- data/app/views/iugu/shared/_links.haml +19 -0
- data/app/views/iugu/unlocks/new.html.haml +8 -0
- data/app/views/layouts/settings.html.haml +46 -0
- data/config/initializers/account_roles.rb +5 -0
- data/config/initializers/devise.rb +242 -0
- data/config/initializers/social_accounts.rb +16 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/locales/devise.pt-BR.yml +55 -0
- data/config/locales/iugu.en.yml +73 -0
- data/config/locales/iugu.pt-BR.yml +73 -0
- data/config/routes.rb +77 -0
- data/db/migrate/20120528164634_create_account.rb +11 -0
- data/db/migrate/20120529134109_add_devise_to_users.rb +53 -0
- data/db/migrate/20120529162901_add_birthdate_and_name_to_user.rb +12 -0
- data/db/migrate/20120529174755_add_name_and_subscription_id_and_user_id_to_account.rb +13 -0
- data/db/migrate/20120529180814_create_account_users.rb +12 -0
- data/db/migrate/20120530114709_remove_user_id_from_accounts.rb +9 -0
- data/db/migrate/20120531171438_create_account_roles.rb +12 -0
- data/db/migrate/20120604131034_add_locale_to_user.rb +9 -0
- data/db/migrate/20120605142527_create_social_account.rb +15 -0
- data/db/migrate/20120612141130_set_locale.rb +6 -0
- data/db/migrate/20120613173114_remove_unique_from_user_email.rb +11 -0
- data/db/migrate/20120615180728_create_delayed_jobs.rb +22 -0
- data/db/migrate/20120629154429_create_user_invitations.rb +14 -0
- data/db/migrate/20120629195345_add_token_to_user_invitations.rb +8 -0
- data/db/migrate/20120705202827_add_roles_to_user_invitations.rb +8 -0
- data/db/migrate/20120716145846_create_account_domain.rb +14 -0
- data/db/migrate/20120719162426_add_subdomain_to_account.rb +9 -0
- data/lib/iugusdk.rb +73 -0
- data/lib/iugusdk/controllers/helpers.rb +45 -0
- data/lib/iugusdk/engine.rb +13 -0
- data/lib/iugusdk/locale_filter.rb +12 -0
- data/lib/iugusdk/root_tenancy_url.rb +22 -0
- data/lib/iugusdk/valid_tenancy_urls.rb +27 -0
- data/lib/iugusdk/version.rb +3 -0
- data/lib/tasks/iugusdk_tasks.rake +4 -0
- data/spec/controller_macros.rb +41 -0
- data/spec/controllers/account_controller_spec.rb +155 -0
- data/spec/controllers/account_domains_controller_spec.rb +173 -0
- data/spec/controllers/account_roles_controller_spec.rb +48 -0
- data/spec/controllers/account_settings_controller_spec.rb +42 -0
- data/spec/controllers/account_users_controller_spec.rb +145 -0
- data/spec/controllers/application_domain_controller_spec.rb +29 -0
- data/spec/controllers/invitations_controller_spec.rb +102 -0
- data/spec/controllers/profile_controller_spec.rb +125 -0
- data/spec/controllers/settings_controller_spec.rb +14 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +9 -0
- data/spec/dummy/app/assets/stylesheets/application.css +7 -0
- data/spec/dummy/app/assets/stylesheets/default.sass +111 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/dashboard_controller.rb +8 -0
- data/spec/dummy/app/controllers/my_dummy_controller.rb +9 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/dashboard/index.html.haml +5 -0
- data/spec/dummy/app/views/dashboard/splash.html.haml +10 -0
- data/spec/dummy/app/views/layouts/application.html.erb +29 -0
- data/spec/dummy/app/views/layouts/dummy.html.erb +22 -0
- data/spec/dummy/app/views/my_dummy/index.html.haml +5 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/account_roles.yml +3 -0
- data/spec/dummy/config/application.rb +66 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +37 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +60 -0
- data/spec/dummy/config/environments/test.rb +40 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/iugusdk.rb +4 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +69 -0
- data/spec/dummy/config/social_accounts.yml +6 -0
- data/spec/dummy/db/schema.rb +95 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/tmp/cache/sass/1f198e4a81e57d6c86c6fff1f0e13592b233ebc2/prettify.cssc +0 -0
- data/spec/dummy/tmp/cache/sass/40796b6ca2cf9112b889007328d8a4c5fdc634d8/_css3.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/40796b6ca2cf9112b889007328d8a4c5fdc634d8/_support.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/components.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/iugu-ux.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/mixins.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/reset.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/typography.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/utilities.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/589e829967f8e21bd017e2d6a46ea53360f10fe0/variables.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_appearance.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_background-clip.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_background-origin.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_background-size.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_border-radius.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_box-shadow.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_box-sizing.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_box.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_columns.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_font-face.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_images.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_inline-block.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_opacity.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_shared.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_text-shadow.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_transform.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/7694fbc0853be2496915aae45b37e2d934ffc111/_transition.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/9da4e62a062dae83baa33f29455be2ba30cf5dce/_sprites.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/db2a23483187bf5625185da2d6f47de2a6de4989/_base.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/db2a23483187bf5625185da2d6f47de2a6de4989/_sprite-img.scssc +0 -0
- data/spec/dummy/tmp/cache/sass/e5be18dde92936a4632e65289dad5788ed73dd60/base_settings.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/e5be18dde92936a4632e65289dad5788ed73dd60/settings.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/application.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/base_settings.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/e764476e9a85279ad82622591ce49983ed21c149/default.sassc +0 -0
- data/spec/dummy/tmp/cache/sass/eab9c0816f626278a6731ce2928de6fdbe99322b/_hacks.scssc +0 -0
- data/spec/dummy/tmp/restart.txt +0 -0
- data/spec/fabricators/account_domain_fabricator.rb +4 -0
- data/spec/fabricators/account_fabricator.rb +4 -0
- data/spec/fabricators/account_role_fabricator.rb +3 -0
- data/spec/fabricators/account_user_fabricator.rb +4 -0
- data/spec/fabricators/social_account_fabricator.rb +10 -0
- data/spec/fabricators/user_fabricator.rb +10 -0
- data/spec/fabricators/user_invitation_fabricator.rb +4 -0
- data/spec/mailers/iugu_mailer_spec.rb +22 -0
- data/spec/models/account_domain_spec.rb +111 -0
- data/spec/models/account_role_spec.rb +24 -0
- data/spec/models/account_spec.rb +155 -0
- data/spec/models/account_user_spec.rb +158 -0
- data/spec/models/social_account_spec.rb +36 -0
- data/spec/models/user_invitation_spec.rb +92 -0
- data/spec/models/user_spec.rb +187 -0
- data/spec/requests/account_domain_spec.rb +77 -0
- data/spec/requests/account_roles_spec.rb +45 -0
- data/spec/requests/account_spec.rb +97 -0
- data/spec/requests/account_users_spec.rb +129 -0
- data/spec/requests/omniauth_spec.rb +79 -0
- data/spec/requests/settings_spec.rb +53 -0
- data/spec/requests/user_invitation_spec.rb +40 -0
- data/spec/requests/user_spec.rb +34 -0
- data/spec/spec_helper.rb +116 -0
- data/spec/validators/email_validator_spec.rb +21 -0
- metadata +729 -0
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Iugu::AccountDomainsController do
|
4
|
+
context "index" do
|
5
|
+
login_as_user
|
6
|
+
before(:each) do
|
7
|
+
@account = @user.accounts.first
|
8
|
+
@account.account_domains << Fabricate(:account_domain)
|
9
|
+
get :index, :account_id => @account.id
|
10
|
+
end
|
11
|
+
|
12
|
+
it { response.should render_template "iugu/account_domains/index" }
|
13
|
+
end
|
14
|
+
|
15
|
+
context "create" do
|
16
|
+
login_as_user
|
17
|
+
before(:each) do
|
18
|
+
@account = @user.accounts.first
|
19
|
+
post :create, :account_id => @account.id, :account_domain => { :url => "new.test.net" }
|
20
|
+
end
|
21
|
+
|
22
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
23
|
+
|
24
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_created") }
|
25
|
+
|
26
|
+
context "without required fields" do
|
27
|
+
before(:each) do
|
28
|
+
post :create, :account_id => @account.id, :account_domain => {}
|
29
|
+
end
|
30
|
+
|
31
|
+
it { response.should render_template 'iugu/account_domains/index' }
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "destroy" do
|
37
|
+
login_as_user
|
38
|
+
before(:each) do
|
39
|
+
@account = @user.accounts.first
|
40
|
+
@account.account_domains << Fabricate(:account_domain){ url "destroy.test.net" }
|
41
|
+
@domain = @account.account_domains.last
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when using a valid id" do
|
45
|
+
before(:each) do
|
46
|
+
delete :destroy, :account_id => @account.id, :domain_id => @domain.id
|
47
|
+
end
|
48
|
+
|
49
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
50
|
+
|
51
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_destroyed") }
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when using an invalid id" do
|
56
|
+
before(:each) do
|
57
|
+
delete :destroy, :account_id => @account.id, :domain_id => 1273816283761238716
|
58
|
+
end
|
59
|
+
|
60
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
61
|
+
|
62
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_not_found") }
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "instructions" do
|
68
|
+
login_as_user
|
69
|
+
before(:each) do
|
70
|
+
@account = @user.accounts.first
|
71
|
+
@account.account_domains << Fabricate(:account_domain){ url "instructions.test.net" }
|
72
|
+
@domain = @account.account_domains.last
|
73
|
+
end
|
74
|
+
|
75
|
+
context "when using a valid id" do
|
76
|
+
before(:each) do
|
77
|
+
get :instructions, :account_id => @account.id, :domain_id => @domain.id
|
78
|
+
end
|
79
|
+
|
80
|
+
it { response.should render_template "iugu/account_domains/instructions" }
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when using an invalid id" do
|
84
|
+
before(:each) do
|
85
|
+
get :instructions, :account_id => @account.id, :domain_id => 1209371923812238
|
86
|
+
end
|
87
|
+
|
88
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
89
|
+
|
90
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_not_found") }
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "verify" do
|
96
|
+
login_as_user
|
97
|
+
before(:each) do
|
98
|
+
@account = @user.accounts.first
|
99
|
+
@account.account_domains << Fabricate(:account_domain){ url "verify.test.net" }
|
100
|
+
@domain = @account.account_domains.last
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when using a valid id" do
|
104
|
+
|
105
|
+
context "and domain is successfully verified" do
|
106
|
+
before(:each) do
|
107
|
+
stub.any_instance_of(AccountDomain).verify { true }
|
108
|
+
get :verify, :account_id => @account.id, :domain_id => @domain.id
|
109
|
+
end
|
110
|
+
|
111
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
112
|
+
|
113
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_verified") }
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
context "and domain could not be verified" do
|
118
|
+
before(:each) do
|
119
|
+
stub.any_instance_of(AccountDomain).verify { false }
|
120
|
+
get :verify, :account_id => @account.id, :domain_id => @domain.id
|
121
|
+
end
|
122
|
+
|
123
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
124
|
+
|
125
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_not_verified") }
|
126
|
+
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "when receive an invalid id" do
|
131
|
+
before(:each) do
|
132
|
+
get :verify, :account_id => @account.id, :domain_id => 1231241241231241231234
|
133
|
+
end
|
134
|
+
|
135
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
136
|
+
|
137
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_not_found") }
|
138
|
+
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
context "primary" do
|
143
|
+
login_as_user
|
144
|
+
before(:each) do
|
145
|
+
@account = @user.accounts.first
|
146
|
+
@account.account_domains << Fabricate(:account_domain){ url "primary.test.net" }
|
147
|
+
@domain = @account.account_domains.last
|
148
|
+
end
|
149
|
+
|
150
|
+
context "when receive a valid id" do
|
151
|
+
before(:each) do
|
152
|
+
post :primary, :account_id => @account.id, :domain_id => @domain.id
|
153
|
+
end
|
154
|
+
|
155
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
156
|
+
|
157
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_set_primary") }
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
context "when receive an invalid id" do
|
162
|
+
before(:each) do
|
163
|
+
post :primary, :account_id => @account.id, :domain_id => 1231241243141314
|
164
|
+
end
|
165
|
+
|
166
|
+
it { response.should redirect_to account_domains_index_path(@account.id) }
|
167
|
+
|
168
|
+
it { flash.now[:notice].should == I18n.t("iugu.notices.domain_not_found") }
|
169
|
+
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Iugu::AccountRolesController do
|
4
|
+
|
5
|
+
context "edit" do
|
6
|
+
login_as_user
|
7
|
+
|
8
|
+
context "when current_user owns the account" do
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
@current_account_user = @user.account_users.first
|
12
|
+
@current_account_user.set_roles(["owner"])
|
13
|
+
get :edit, :id => @current_account_user.account_id, :user_id => @current_account_user.user_id
|
14
|
+
end
|
15
|
+
|
16
|
+
it { response.should render_template "iugu/account_roles/edit" }
|
17
|
+
it { response.should be_success }
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when current_user do not owns the account" do
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@current_account_user = @user.account_users.first
|
25
|
+
@account = @current_account_user.account
|
26
|
+
@account.account_users << Fabricate(:account_user) { user Fabricate(:user) { email "notowner@account.test" } }
|
27
|
+
@current_account_user.set_roles(["user"])
|
28
|
+
get :edit, :id => @current_account_user.account_id, :user_id => @current_account_user.user_id
|
29
|
+
end
|
30
|
+
|
31
|
+
it { response.should_not render_template "iugu/account_roles/edit" }
|
32
|
+
it { response.should_not be_success }
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
context "update" do
|
38
|
+
login_as_user
|
39
|
+
before(:each) do
|
40
|
+
@account_id = @user.account_users.first.account_id
|
41
|
+
post :update, :id => @account_id, :user_id => @user.id, :roles => []
|
42
|
+
end
|
43
|
+
|
44
|
+
it { response.should redirect_to account_users_index_path(@account_id)}
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class StubAccountSettingsController < Iugu::AccountSettingsController
|
4
|
+
|
5
|
+
def index
|
6
|
+
render :text => "true", :status => 200
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
describe StubAccountSettingsController do
|
12
|
+
|
13
|
+
def with_stub_routing
|
14
|
+
with_routing do |map|
|
15
|
+
map.draw do
|
16
|
+
match '/stub/account/settings/index' => "stub_account_settings#index"
|
17
|
+
end
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
before(:each) do
|
23
|
+
@account = Fabricate(:account)
|
24
|
+
end
|
25
|
+
login_as_user
|
26
|
+
|
27
|
+
it 'should render 404' do
|
28
|
+
@account.destroy
|
29
|
+
with_stub_routing do
|
30
|
+
get :index, :account_id => @account.id
|
31
|
+
end
|
32
|
+
response.should_not be_success
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should not render 404' do
|
36
|
+
with_stub_routing do
|
37
|
+
get :index, :account_id => @account.id
|
38
|
+
end
|
39
|
+
response.should be_success
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Iugu::AccountUsersController do
|
4
|
+
context "index" do
|
5
|
+
login_as_user
|
6
|
+
before(:each) do
|
7
|
+
get :index, :account_id => @user.accounts.first.id
|
8
|
+
end
|
9
|
+
|
10
|
+
it { response.should render_template 'iugu/account_users/index' }
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
context "view" do
|
15
|
+
login_as_user
|
16
|
+
before(:each) do
|
17
|
+
get :view, :account_id => @user.accounts.first.id, :user_id => @user.id
|
18
|
+
end
|
19
|
+
|
20
|
+
it { response.should render_template 'iugu/account_users/view' }
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "destroy" do
|
25
|
+
login_as_user
|
26
|
+
before(:each) do
|
27
|
+
@account = @user.accounts.first
|
28
|
+
end
|
29
|
+
|
30
|
+
context "when current_user is account owner/admin" do
|
31
|
+
|
32
|
+
before(:each) do
|
33
|
+
@target_user = Fabricate(:user) do
|
34
|
+
email 'target@teste.teste'
|
35
|
+
end
|
36
|
+
@account.account_users << @account_user = AccountUser.create(:user_id => @target_user.id)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should raise routing error if account_id is invalid' do
|
40
|
+
lambda {
|
41
|
+
get :destroy, :account_id => 1892731892371273, :user_id => @target_user.id
|
42
|
+
}.should raise_error ActionController::RoutingError
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should raise routing error if user_id is invalid' do
|
46
|
+
lambda {
|
47
|
+
get :destroy, :account_id => @account.id, :user_id => 18237198237192837
|
48
|
+
}.should raise_error ActionController::RoutingError
|
49
|
+
end
|
50
|
+
|
51
|
+
context "and delete a non owner account" do
|
52
|
+
before(:each) do
|
53
|
+
@account_user.set_roles ["user"]
|
54
|
+
get :destroy, :account_id => @account.id, :user_id => @target_user.id
|
55
|
+
end
|
56
|
+
|
57
|
+
it { response.should redirect_to account_users_index_path(@account.id) }
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
context "and dele an owner account" do
|
63
|
+
before(:each) do
|
64
|
+
@account_user.set_roles ["owner"]
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should raise routing error' do
|
68
|
+
lambda {
|
69
|
+
get :destroy, :account_id => @account.id, :user_id => @target_user.id
|
70
|
+
}.should raise_error ActionController::RoutingError
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context "and try to delete itself from the account" do
|
76
|
+
before(:each) do
|
77
|
+
@account.account_users.find_by_user_id(@user.id).set_roles ["admin"]
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should raise routing error' do
|
81
|
+
lambda {
|
82
|
+
get :destroy, :account_id => @account.id, :user_id => @user.id
|
83
|
+
}.should raise_error ActionController::RoutingError
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
context "cancel_destruction" do
|
93
|
+
login_as_user
|
94
|
+
before(:each) do
|
95
|
+
@account = @user.accounts.first
|
96
|
+
@target_user = Fabricate(:user) do
|
97
|
+
email 'target@test.test'
|
98
|
+
end
|
99
|
+
@account.account_users << @account_user = AccountUser.create(:user_id => @target_user.id)
|
100
|
+
@account_user.set_roles ["user"]
|
101
|
+
@account_user.destroy
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should raise routing error if account_id is invalid' do
|
105
|
+
lambda {
|
106
|
+
get :cancel_destruction, :account_id => 1892731892371273, :user_id => @target_user.id
|
107
|
+
}.should raise_error ActionController::RoutingError
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should raise routing error if user_id is invalid' do
|
111
|
+
lambda {
|
112
|
+
get :cancel_destruction, :account_id => @account.id, :user_id => 18237198237192837
|
113
|
+
}.should raise_error ActionController::RoutingError
|
114
|
+
end
|
115
|
+
|
116
|
+
context "when current user is owner/admin" do
|
117
|
+
before(:each) do
|
118
|
+
AccountUser.find_by_user_id_and_account_id(@user.id, @account.id).set_roles ["owner"]
|
119
|
+
delete :cancel_destruction, :account_id => @account.id, :user_id => @target_user.id
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should cancel account_user destruction' do
|
123
|
+
@account_user.destroying?.should be_false
|
124
|
+
end
|
125
|
+
|
126
|
+
it { response.should redirect_to account_users_index_path(@account.id) }
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
context "when current user is not owner/admin" do
|
131
|
+
before(:each) do
|
132
|
+
@account.account_users << Fabricate(:account_user) { user Fabricate(:user) { email "notowner@account.test" } }
|
133
|
+
AccountUser.find_by_user_id_and_account_id(@user.id, @account.id).set_roles ["user"]
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should raise routing error' do
|
137
|
+
lambda {
|
138
|
+
delete :cancel_destruction, :account_id => @account.id, :user_id => @target_user.id
|
139
|
+
}.should raise_error ActionController::RoutingError
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class StubApplicationDomainController < Iugu::ApplicationDomainController
|
4
|
+
|
5
|
+
def index
|
6
|
+
render :text => "true", :status => 200
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
describe StubApplicationDomainController do
|
12
|
+
|
13
|
+
def with_stub_routing
|
14
|
+
with_routing do |map|
|
15
|
+
map.draw do
|
16
|
+
match '/stub/application/domain/index' => "stub_application_domain#index"
|
17
|
+
end
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should be_success' do
|
23
|
+
with_stub_routing do
|
24
|
+
get :index
|
25
|
+
end
|
26
|
+
response.should be_success
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Iugu::InvitationsController do
|
4
|
+
context "before filter" do
|
5
|
+
|
6
|
+
context "when user dont have permissions on account" do
|
7
|
+
login_as_user
|
8
|
+
before(:each) do
|
9
|
+
@account = Fabricate(:account)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should raise routing error' do
|
13
|
+
lambda {
|
14
|
+
get :new, :account_id => @account
|
15
|
+
}.should raise_error ActionController::RoutingError
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
context "new" do
|
23
|
+
login_as_user
|
24
|
+
before(:each) do
|
25
|
+
@account = @user.accounts.first
|
26
|
+
get :new, :account_id => @account.id
|
27
|
+
end
|
28
|
+
|
29
|
+
it { response.should render_template 'iugu/invitations/new' }
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context "create" do
|
34
|
+
login_as_user
|
35
|
+
before(:each) do
|
36
|
+
@account = @user.accounts.first
|
37
|
+
post :create, :account_id => @account.id, :user_invitation => {:email => "create@controller.teste"}
|
38
|
+
end
|
39
|
+
|
40
|
+
it { response.should redirect_to account_users_index_path(@account.id) }
|
41
|
+
|
42
|
+
it 'should create an invite' do
|
43
|
+
UserInvitation.last.email.should == "create@controller.teste"
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
context "edit" do
|
49
|
+
login_as_user
|
50
|
+
before(:each) do
|
51
|
+
@user_invitation = Fabricate(:user_invitation)
|
52
|
+
@user_invitation.update_attribute(:invited_by, @user.id)
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when token is not valid" do
|
56
|
+
|
57
|
+
it 'should raise routing error' do
|
58
|
+
lambda {
|
59
|
+
put :edit, :invitation_token => "9821aaaaabbbbbaaaaaccccc"
|
60
|
+
}.should raise_error ActionController::RoutingError
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when token is valid" do
|
66
|
+
before(:each) do
|
67
|
+
get :edit, :invitation_token => @user_invitation.id.to_s + @user_invitation.token
|
68
|
+
end
|
69
|
+
|
70
|
+
it { response.should render_template "iugu/invitations/edit" }
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "update" do
|
76
|
+
login_as_user
|
77
|
+
before(:each) do
|
78
|
+
@account = Fabricate(:account)
|
79
|
+
@user_invitation = Fabricate(:user_invitation)
|
80
|
+
@user_invitation.update_attribute(:account_id, @account.id)
|
81
|
+
end
|
82
|
+
|
83
|
+
context "when token is not valid" do
|
84
|
+
|
85
|
+
it 'should raise routing error' do
|
86
|
+
lambda {
|
87
|
+
put :update, :invitation_token => "9821aaaaabbbbbaaaaaccccc"
|
88
|
+
}.should raise_error ActionController::RoutingError
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context "when token is valid" do
|
94
|
+
before(:each) do
|
95
|
+
get :update, :invitation_token => @user_invitation.id.to_s + @user_invitation.token
|
96
|
+
end
|
97
|
+
|
98
|
+
it { response.should redirect_to root_path }
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|