iugusdk 1.0.0.alpha.0 → 1.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,7 @@ class Iugu::AccountController < Iugu::AccountSettingsController
25
25
  end
26
26
  end
27
27
  rescue
28
- notice = "Account not found"
28
+ notice = I18n.t("iugu.notices.account_not_found")
29
29
  end
30
30
  redirect_to(account_settings_path, :notice => notice)
31
31
  end
@@ -35,7 +35,7 @@ class Iugu::AccountController < Iugu::AccountSettingsController
35
35
  current_user.accounts.find(params[:id]).cancel_destruction if params[:id]
36
36
  notice = I18n.t("iugu.account_destruction_undone")
37
37
  rescue
38
- notice = "Account not found"
38
+ notice = I18n.t("iugu.notices.account_not_found")
39
39
  end
40
40
  redirect_to(account_settings_path, :notice => notice)
41
41
  end
@@ -49,7 +49,7 @@ class Iugu::AccountController < Iugu::AccountSettingsController
49
49
  begin
50
50
  @account = Account.find(params[:id])
51
51
  @account.update_attributes(params[:account])
52
- redirect_to(account_view_path(params[:id]))
52
+ redirect_to account_view_path(params[:id]), :notice => I18n.t("iugu.notices.account_updated")
53
53
  rescue
54
54
  raise ActionController::RoutingError.new('Not Found')
55
55
  end
@@ -8,8 +8,8 @@ class Iugu::AccountDomainsController < Iugu::AccountSettingsController
8
8
 
9
9
  def create
10
10
  @account = current_user.accounts.find(params[:account_id])
11
- if @account.account_domains << AccountDomain.create(params[:account_domain])
12
- redirect_to account_domains_index_path(params[:account_id]), :notice => notice = I18n.t("iugu.notices.domain_created")
11
+ if @account.account_domains << @domain = AccountDomain.create(params[:account_domain])
12
+ redirect_to account_domains_instructions_path(:account_id => params[:account_id], :domain_id => @domain.id)#, :notice => notice = I18n.t("iugu.notices.domain_created")
13
13
  else
14
14
  render :index
15
15
  end
@@ -43,7 +43,7 @@ class Iugu::AccountDomainsController < Iugu::AccountSettingsController
43
43
  if @domain.verify
44
44
  redirect_to account_domains_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.domain_verified")
45
45
  else
46
- redirect_to account_domains_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.domain_not_verified")
46
+ redirect_to account_domains_instructions_path(:account_id => params[:account_id], :domain_id => params[:domain_id]), :notice => I18n.t("iugu.notices.domain_not_verified")
47
47
  end
48
48
  rescue
49
49
  redirect_to account_domains_index_path(params[:account_id]), :notice => I18n.t("iugu.notices.domain_not_found")
@@ -7,7 +7,7 @@ class Account < ActiveRecord::Base
7
7
  handle_asynchronously :destroy, :queue => Proc.new { |p| "account_#{p.id}_destroy" },
8
8
  :run_at => Proc.new { DateTime.now + IuguSDK::delay_account_exclusion }
9
9
 
10
- validates :subdomain, :uniqueness => true
10
+ validates :subdomain, :uniqueness => true, :unless => Proc.new { |a| a.subdomain.blank? }
11
11
  validate :subdomain_blacklist
12
12
 
13
13
  def self.get_from_domain(domain)
@@ -4,6 +4,8 @@ class UserInvitation < ActiveRecord::Base
4
4
  before_create :set_sent_at
5
5
  after_create :send_email
6
6
 
7
+ belongs_to :account
8
+
7
9
  def self.find_by_invitation_token(invitation_token)
8
10
  begin
9
11
  user_invitation = UserInvitation.find(id = invitation_token.gsub(/.{27}$/, ''))
@@ -22,8 +22,7 @@
22
22
  - if domain.verified
23
23
  = I18n.t("iugu.verified")
24
24
  - else
25
- = I18n.t("iugu.not_verified")
26
- = link_to I18n.t("iugu.instructions"), account_domains_instructions_path(:account_id => @account.id, :domain_id => domain.id)
25
+ = link_to I18n.t("iugu.not_verified"), account_domains_instructions_path(:account_id => @account.id, :domain_id => domain.id)
27
26
 
28
27
  - if current_user.is?(:owner, @account)
29
28
  |
@@ -0,0 +1,4 @@
1
+ %div
2
+ = link_to I18n.t("iugu.verify_domain"), verify_domain_path(:account_id => @account.id, :domain_id => @domain.id), :method => :post
3
+ %div
4
+ = link_to I18n.t("iugu.verify_later"), account_domains_index_path(@account.id)
@@ -16,8 +16,5 @@
16
16
  = I18n.t("iugu.removing")
17
17
  - else
18
18
  = link_to I18n.t("iugu.undo"), account_users_cancel_destruction_path(:account_id => account_user.account_id, :user_id => account_user.user_id), :method => 'delete'
19
-
20
- %br
21
- %br
22
- %div
23
- = link_to I18n.t("iugu.invite"), new_invite_path(:account_id => @account.id)
19
+ %div
20
+ = link_to I18n.t("iugu.invite"), new_invite_path(:account_id => @account.id)
@@ -58,8 +58,12 @@ en:
58
58
  set_primary: "Set Primary"
59
59
  verified: "Verified"
60
60
  not_verified: "Not Verified"
61
+ verify_domain: "Verify Domain"
62
+ verify_later: "Verify later"
61
63
  instructions: "Instructions"
62
64
  notices:
65
+ account_updated: "Account was successfully updated"
66
+ account_not_found: "Account not found"
63
67
  user_invited: "User invited"
64
68
  sign_up: "Thank you for signing up"
65
69
  user_update: "User was successfully updated."
@@ -58,8 +58,12 @@ pt-BR:
58
58
  set_primary: "Setar primario"
59
59
  verified: "Verificado"
60
60
  not_verified: "Não Verificado"
61
+ verify_domain: "Verificar Dominio"
62
+ verify_later: "Verificar depois"
61
63
  instructions: "Instruções"
62
64
  notices:
65
+ account_updated: "Conta atualizada com sucesso."
66
+ account_not_found: "Conta não encontrada"
63
67
  user_invited: "Usuário convidado"
64
68
  sign_up: "Obrigado por se cadastrar."
65
69
  user_update: "Seus dados foram atualizados."
@@ -1,3 +1,3 @@
1
1
  module IuguSDK
2
- VERSION = "1.0.0.alpha.0"
2
+ VERSION = "1.0.0.alpha.1"
3
3
  end
@@ -47,13 +47,15 @@ describe Iugu::AccountController do
47
47
  end
48
48
  end
49
49
 
50
- context "when using right id" do
50
+ context "when using wrong id" do
51
51
  before do
52
52
  get :destroy, :id => 31241
53
53
  end
54
54
 
55
55
  it { response.should redirect_to account_settings_path }
56
56
 
57
+ it { flash.now[:notice].should == I18n.t("iugu.notices.account_not_found") }
58
+
57
59
  end
58
60
 
59
61
  context "when user is not the owner" do
@@ -101,6 +103,8 @@ describe Iugu::AccountController do
101
103
 
102
104
  it { response.should redirect_to account_settings_path }
103
105
 
106
+ it { flash.now[:notice].should == I18n.t("iugu.notices.account_not_found") }
107
+
104
108
  end
105
109
  end
106
110
 
@@ -122,6 +126,9 @@ describe Iugu::AccountController do
122
126
 
123
127
  it { response.should redirect_to account_view_path(@user.accounts.first.id) }
124
128
 
129
+ it { flash.now[:notice].should == I18n.t("iugu.notices.account_updated") }
130
+
131
+
125
132
  it 'should update account name' do
126
133
  @user.accounts.first.name.should == "fudum"
127
134
  end
@@ -19,9 +19,7 @@ describe Iugu::AccountDomainsController do
19
19
  post :create, :account_id => @account.id, :account_domain => { :url => "new.test.net" }
20
20
  end
21
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") }
22
+ it { response.should redirect_to account_domains_instructions_path(@account.id, AccountDomain.last.id) }
25
23
 
26
24
  context "without required fields" do
27
25
  before(:each) do
@@ -120,7 +118,7 @@ describe Iugu::AccountDomainsController do
120
118
  get :verify, :account_id => @account.id, :domain_id => @domain.id
121
119
  end
122
120
 
123
- it { response.should redirect_to account_domains_index_path(@account.id) }
121
+ it { response.should redirect_to account_domains_instructions_path(@account.id, @domain.id) }
124
122
 
125
123
  it { flash.now[:notice].should == I18n.t("iugu.notices.domain_not_verified") }
126
124
 
@@ -0,0 +1,104 @@
1
+ Connecting to database specified by database.yml
2
+  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
3
+  (81.1ms) DROP DATABASE IF EXISTS `iugusdk_test`
4
+  (0.2ms) CREATE DATABASE `iugusdk_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
5
+  (79.4ms) CREATE TABLE `account_domains` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `account_id` int(11), `url` varchar(255), `verified` tinyint(1), `primary` tinyint(1)) ENGINE=InnoDB
6
+  (227.3ms) CREATE TABLE `account_roles` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `account_user_id` int(11)) ENGINE=InnoDB
7
+  (151.2ms) CREATE TABLE `account_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `account_id` int(11), `user_id` int(11)) ENGINE=InnoDB
8
+  (173.3ms) CREATE TABLE `accounts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime, `updated_at` datetime, `name` varchar(255), `subscription_id` int(11), `subdomain` varchar(255)) ENGINE=InnoDB
9
+  (79.1ms) CREATE TABLE `delayed_jobs` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `priority` int(11) DEFAULT 0, `attempts` int(11) DEFAULT 0, `handler` text, `last_error` text, `run_at` datetime, `locked_at` datetime, `failed_at` datetime, `locked_by` varchar(255), `queue` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
10
+  (186.2ms) CREATE INDEX `delayed_jobs_priority` ON `delayed_jobs` (`priority`, `run_at`)
11
+  (120.2ms) CREATE TABLE `social_accounts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `social_id` int(11), `user_id` int(11), `provider` varchar(255), `token` varchar(255), `secret` varchar(255)) ENGINE=InnoDB
12
+  (164.0ms) CREATE TABLE `user_invitations` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `invited_by` int(11), `email` varchar(255), `sent_at` datetime, `account_id` int(11), `token` varchar(255), `roles` varchar(255)) ENGINE=InnoDB
13
+  (125.3ms) CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `email` varchar(255) DEFAULT '' NOT NULL, `encrypted_password` varchar(255) DEFAULT '' NOT NULL, `reset_password_token` varchar(255), `reset_password_sent_at` datetime, `remember_created_at` datetime, `confirmation_token` varchar(255), `confirmed_at` datetime, `confirmation_sent_at` datetime, `unconfirmed_email` varchar(255), `created_at` datetime, `updated_at` datetime, `birthdate` date, `name` varchar(255), `locale` varchar(255)) ENGINE=InnoDB
14
+  (188.6ms) CREATE UNIQUE INDEX `index_users_on_confirmation_token` ON `users` (`confirmation_token`)
15
+  (108.9ms) CREATE INDEX `index_users_on_email` ON `users` (`email`)
16
+  (132.2ms) CREATE UNIQUE INDEX `index_users_on_reset_password_token` ON `users` (`reset_password_token`)
17
+  (176.2ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
18
+  (169.6ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
19
+  (0.1ms) SELECT version FROM `schema_migrations`
20
+  (1.4ms) INSERT INTO `schema_migrations` (version) VALUES ('20120719162426')
21
+ Connecting to database specified by database.yml
22
+  (83.8ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
23
+  (268.8ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
24
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
25
+ Migrating to CreateAccount (20120528164634)
26
+  (97.7ms) CREATE TABLE `accounts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
27
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120528164634')
28
+ Migrating to AddDeviseToUsers (20120529134109)
29
+  (152.1ms) CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `email` varchar(255) DEFAULT '' NOT NULL, `encrypted_password` varchar(255) DEFAULT '' NOT NULL, `reset_password_token` varchar(255), `reset_password_sent_at` datetime, `remember_created_at` datetime, `confirmation_token` varchar(255), `confirmed_at` datetime, `confirmation_sent_at` datetime, `unconfirmed_email` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
30
+  (129.8ms) CREATE UNIQUE INDEX `index_users_on_email` ON `users` (`email`)
31
+  (111.3ms) CREATE UNIQUE INDEX `index_users_on_reset_password_token` ON `users` (`reset_password_token`)
32
+  (117.0ms) CREATE UNIQUE INDEX `index_users_on_confirmation_token` ON `users` (`confirmation_token`)
33
+  (1.4ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120529134109')
34
+ Migrating to AddBirthdateAndNameToUser (20120529162901)
35
+  (145.8ms) ALTER TABLE `users` ADD `birthdate` date
36
+  (151.3ms) ALTER TABLE `users` ADD `name` varchar(255)
37
+  (0.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120529162901')
38
+ Migrating to AddNameAndSubscriptionIdAndUserIdToAccount (20120529174755)
39
+  (106.1ms) ALTER TABLE `accounts` ADD `name` varchar(255)
40
+  (124.4ms) ALTER TABLE `accounts` ADD `subscription_id` int(11)
41
+  (99.8ms) ALTER TABLE `accounts` ADD `user_id` int(11)
42
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120529174755')
43
+ Migrating to CreateAccountUsers (20120529180814)
44
+  (124.5ms) CREATE TABLE `account_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `account_id` int(11), `user_id` int(11)) ENGINE=InnoDB
45
+  (0.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120529180814')
46
+ Migrating to RemoveUserIdFromAccounts (20120530114709)
47
+  (119.3ms) ALTER TABLE `accounts` DROP `user_id`
48
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120530114709')
49
+ Migrating to CreateAccountRoles (20120531171438)
50
+  (119.0ms) CREATE TABLE `account_roles` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `account_user_id` int(11)) ENGINE=InnoDB
51
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120531171438')
52
+ Migrating to AddLocaleToUser (20120604131034)
53
+  (114.9ms) ALTER TABLE `users` ADD `locale` varchar(255)
54
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120604131034')
55
+ Migrating to CreateSocialAccount (20120605142527)
56
+  (94.3ms) CREATE TABLE `social_accounts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `social_id` int(11), `user_id` int(11), `provider` varchar(255), `token` varchar(255), `secret` varchar(255)) ENGINE=InnoDB
57
+  (1.0ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120605142527')
58
+ Migrating to SetLocale (20120612141130)
59
+ SQL (0.3ms) UPDATE `users` SET locale = 'en' WHERE `users`.`locale` IS NULL
60
+  (0.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120612141130')
61
+ Migrating to RemoveUniqueFromUserEmail (20120613173114)
62
+  (95.9ms) DROP INDEX `index_users_on_email` ON `users`
63
+  (162.1ms) CREATE INDEX `index_users_on_email` ON `users` (`email`)
64
+  (0.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120613173114')
65
+ Migrating to CreateDelayedJobs (20120615180728)
66
+  (95.0ms) CREATE TABLE `delayed_jobs` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `priority` int(11) DEFAULT 0, `attempts` int(11) DEFAULT 0, `handler` text, `last_error` text, `run_at` datetime, `locked_at` datetime, `failed_at` datetime, `locked_by` varchar(255), `queue` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
67
+  (181.6ms) CREATE INDEX `delayed_jobs_priority` ON `delayed_jobs` (`priority`, `run_at`)
68
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120615180728')
69
+ Migrating to CreateUserInvitations (20120629154429)
70
+  (182.3ms) CREATE TABLE `user_invitations` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `invited_by` int(11), `email` varchar(255), `sent_at` datetime, `account_id` int(11)) ENGINE=InnoDB
71
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120629154429')
72
+ Migrating to AddTokenToUserInvitations (20120629195345)
73
+  (155.6ms) ALTER TABLE `user_invitations` ADD `token` varchar(255)
74
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120629195345')
75
+ Migrating to AddRolesToUserInvitations (20120705202827)
76
+  (94.5ms) ALTER TABLE `user_invitations` ADD `roles` varchar(255)
77
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120705202827')
78
+ Migrating to CreateAccountDomain (20120716145846)
79
+  (127.2ms) CREATE TABLE `account_domains` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `account_id` int(11), `url` varchar(255), `verified` tinyint(1), `primary` tinyint(1)) ENGINE=InnoDB
80
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120716145846')
81
+ Migrating to AddSubdomainToAccount (20120719162426)
82
+  (115.4ms) ALTER TABLE `accounts` ADD `subdomain` varchar(255)
83
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120719162426')
84
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
85
+ Connecting to database specified by database.yml
86
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
87
+  (0.4ms) DROP DATABASE IF EXISTS `iugusdk_test`
88
+  (0.2ms) CREATE DATABASE `iugusdk_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
89
+  (54.8ms) CREATE TABLE `account_domains` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `account_id` int(11), `url` varchar(255), `verified` tinyint(1), `primary` tinyint(1)) ENGINE=InnoDB
90
+  (257.1ms) CREATE TABLE `account_roles` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `account_user_id` int(11)) ENGINE=InnoDB
91
+  (106.9ms) CREATE TABLE `account_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `account_id` int(11), `user_id` int(11)) ENGINE=InnoDB
92
+  (117.9ms) CREATE TABLE `accounts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `name` varchar(255), `subscription_id` int(11), `subdomain` varchar(255)) ENGINE=InnoDB
93
+  (138.2ms) CREATE TABLE `delayed_jobs` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `priority` int(11) DEFAULT 0, `attempts` int(11) DEFAULT 0, `handler` text, `last_error` text, `run_at` datetime, `locked_at` datetime, `failed_at` datetime, `locked_by` varchar(255), `queue` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
94
+  (117.6ms) CREATE INDEX `delayed_jobs_priority` ON `delayed_jobs` (`priority`, `run_at`)
95
+  (170.1ms) CREATE TABLE `social_accounts` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `social_id` int(11), `user_id` int(11), `provider` varchar(255), `token` varchar(255), `secret` varchar(255)) ENGINE=InnoDB
96
+  (164.0ms) CREATE TABLE `user_invitations` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `invited_by` int(11), `email` varchar(255), `sent_at` datetime, `account_id` int(11), `token` varchar(255), `roles` varchar(255)) ENGINE=InnoDB
97
+  (115.6ms) CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `email` varchar(255) DEFAULT '' NOT NULL, `encrypted_password` varchar(255) DEFAULT '' NOT NULL, `reset_password_token` varchar(255), `reset_password_sent_at` datetime, `remember_created_at` datetime, `confirmation_token` varchar(255), `confirmed_at` datetime, `confirmation_sent_at` datetime, `unconfirmed_email` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `birthdate` date, `name` varchar(255), `locale` varchar(255)) ENGINE=InnoDB
98
+  (123.5ms) CREATE UNIQUE INDEX `index_users_on_confirmation_token` ON `users` (`confirmation_token`)
99
+  (133.4ms) CREATE INDEX `index_users_on_email` ON `users` (`email`)
100
+  (148.4ms) CREATE UNIQUE INDEX `index_users_on_reset_password_token` ON `users` (`reset_password_token`)
101
+  (134.7ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
102
+  (128.7ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
103
+  (0.1ms) SELECT version FROM `schema_migrations`
104
+  (0.5ms) INSERT INTO `schema_migrations` (version) VALUES ('20120719162426')