saucy 0.5.1 → 0.5.2
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/CHANGELOG.md +12 -2
- data/app/models/signup.rb +24 -14
- data/app/views/accounts/edit.html.erb +1 -1
- data/app/views/accounts/new.html.erb +2 -8
- data/app/views/shared/_saucy_javascript.html.erb +3 -3
- data/lib/generators/saucy/features/features_generator.rb +3 -2
- data/lib/generators/saucy/features/templates/factories.rb +0 -4
- data/lib/generators/saucy/features/templates/features/manage_account.feature +0 -1
- data/lib/generators/saucy/features/templates/features/manage_billing.feature +1 -2
- data/lib/generators/saucy/features/templates/features/new_account.feature +6 -21
- data/lib/generators/saucy/features/templates/features/sign_up.feature +0 -5
- data/lib/generators/saucy/features/templates/features/sign_up_paid.feature +0 -13
- data/lib/generators/saucy/features/templates/features/trial_plans.feature +1 -5
- data/lib/generators/saucy/features/templates/step_definitions/account_steps.rb +11 -0
- data/spec/models/signup_spec.rb +19 -46
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
0.5.2
|
2
|
+
|
3
|
+
Simplifies the signup process to asking users for just an email and password.
|
4
|
+
Overall this should be seamless upgrade but you may have made other changes in
|
5
|
+
your application which might conflict, just pay attention when you upgrade.
|
6
|
+
|
7
|
+
You'll defintely want to make sure you regerate the saucy features with this upgrade:
|
8
|
+
|
9
|
+
rails g saucy:features
|
10
|
+
|
1
11
|
0.5.1
|
2
12
|
|
3
13
|
Add an index to the archived column for projects
|
@@ -17,8 +27,8 @@ account. An introduced headers to these two lists. Archived projects have
|
|
17
27
|
a "View Project" link, which is how the user can view an archived project.
|
18
28
|
You will probably want to style this list, headers, and link.
|
19
29
|
|
20
|
-
It also adds an Archive link on the project's edit page. You will probably
|
21
|
-
want to style
|
30
|
+
It also adds an Archive/Unarchive link on the project's edit page. You will probably
|
31
|
+
want to style these links.
|
22
32
|
|
23
33
|
It is up to your application to provide any additional logic about what
|
24
34
|
limitations are present for archived projects (for example, not being able to
|
data/app/models/signup.rb
CHANGED
@@ -7,8 +7,6 @@ class Signup
|
|
7
7
|
|
8
8
|
FIELDS = {
|
9
9
|
:account => {
|
10
|
-
:name => :account_name,
|
11
|
-
:keyword => :keyword,
|
12
10
|
:cardholder_name => :cardholder_name,
|
13
11
|
:billing_email => :billing_email,
|
14
12
|
:card_number => :card_number,
|
@@ -18,16 +16,13 @@ class Signup
|
|
18
16
|
:plan => :plan
|
19
17
|
},
|
20
18
|
:user => {
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:password => :password,
|
24
|
-
:password_confirmation => :password_confirmation,
|
19
|
+
:email => :email,
|
20
|
+
:password => :password,
|
25
21
|
}
|
26
22
|
}.freeze
|
27
23
|
|
28
|
-
attr_accessor :
|
29
|
-
:
|
30
|
-
:expiration_month, :expiration_year, :plan, :verification_code
|
24
|
+
attr_accessor :billing_email, :password, :cardholder_name, :email,
|
25
|
+
:card_number, :expiration_month, :expiration_year, :plan, :verification_code
|
31
26
|
|
32
27
|
def initialize(attributes = {})
|
33
28
|
if attributes
|
@@ -45,7 +40,12 @@ class Signup
|
|
45
40
|
|
46
41
|
def save
|
47
42
|
delegate_attributes_for(:account)
|
48
|
-
|
43
|
+
populate_additional_account_fields
|
44
|
+
|
45
|
+
if !existing_user
|
46
|
+
delegate_attributes_for(:user)
|
47
|
+
populate_additional_user_fields
|
48
|
+
end
|
49
49
|
|
50
50
|
if valid?
|
51
51
|
begin
|
@@ -94,11 +94,21 @@ class Signup
|
|
94
94
|
errors.empty?
|
95
95
|
end
|
96
96
|
|
97
|
-
|
98
|
-
|
97
|
+
private
|
98
|
+
|
99
|
+
def short_name
|
100
|
+
email.split(/@/).first if email.present?
|
101
|
+
end
|
102
|
+
|
103
|
+
def populate_additional_account_fields
|
104
|
+
account.name = "#{short_name}"
|
105
|
+
account.keyword = "#{short_name}#{SecureRandom.hex(3)}"
|
99
106
|
end
|
100
107
|
|
101
|
-
|
108
|
+
def populate_additional_user_fields
|
109
|
+
user.name = short_name
|
110
|
+
user.password_confirmation = password
|
111
|
+
end
|
102
112
|
|
103
113
|
def delegate_attributes_for(model_name)
|
104
114
|
FIELDS[model_name].each do |target, source|
|
@@ -115,7 +125,7 @@ class Signup
|
|
115
125
|
def delegate_errors_for(model_name)
|
116
126
|
fields = FIELDS[model_name]
|
117
127
|
send(model_name).errors.each do |field, message|
|
118
|
-
errors.add(fields[field], message)
|
128
|
+
errors.add(fields[field], message) if fields[field]
|
119
129
|
end
|
120
130
|
end
|
121
131
|
|
@@ -9,20 +9,14 @@
|
|
9
9
|
<%= link_to "Change this plan", plans_path %>
|
10
10
|
</div>
|
11
11
|
|
12
|
-
<h5 class="legend">Basic Information</h5>
|
13
|
-
<%= form.inputs do %>
|
14
|
-
<%= form.input :account_name, :label => 'Company Name', :hint => account_url(Account.new(:keyword => 'keyword')).html_safe, :required => true %>
|
15
|
-
<%= form.input :keyword, :wrapper_html => { :style => 'display: none' } %>
|
16
|
-
<% end %>
|
17
|
-
|
18
12
|
<% unless signed_in? -%>
|
19
13
|
<h5 class="legend">User Information</h5>
|
20
14
|
<%= form.inputs do %>
|
21
|
-
<%= form.input :user_name, :label => "Your name", :required => true %>
|
22
15
|
<%= form.input :email, :required => true %>
|
23
16
|
<%= form.input :password, :required => true %>
|
24
|
-
<%= form.input :password_confirmation, :label => "Confirm password", :required => true %>
|
25
17
|
<% end -%>
|
18
|
+
<% else -%>
|
19
|
+
<p id="existing-user-text">Your existing user, <strong><%= current_user.name %></strong>, will be added as the first administrator on this new account.</p>
|
26
20
|
<% end -%>
|
27
21
|
|
28
22
|
<% if @plan.billed? -%>
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<%= content_for :javascript do -%>
|
2
2
|
<%= javascript_tag do %>
|
3
3
|
$(function() {
|
4
|
-
$('#
|
4
|
+
$('#project_name_input p.inline-hints').each(function(index) {
|
5
5
|
$(this).html($(this).text().replace("keyword", "<span>keyword</span>"))
|
6
6
|
});
|
7
|
-
$('#
|
7
|
+
$('#project_name').keyup(function(){
|
8
8
|
var mainPart = /^([\w\s]*)(\W*)/.exec($(this).val())[1];
|
9
9
|
mainPart = mainPart.replace(/ /g, "").toLowerCase();
|
10
10
|
if(mainPart == "") mainPart = "keyword";
|
11
11
|
$(this).siblings('p.inline-hints').find('span').text(mainPart);
|
12
|
-
$('#
|
12
|
+
$('#project_keyword').val(mainPart);
|
13
13
|
});
|
14
14
|
|
15
15
|
$.fn.updateSelectedPlan = function() {
|
@@ -54,8 +54,9 @@ DESC
|
|
54
54
|
when /^the upgrade plan page for the "([^"]+)" account$/
|
55
55
|
account = Account.find_by_name!($1)
|
56
56
|
edit_account_plan_path(account)
|
57
|
-
when /^the new project page for the "([^"]
|
58
|
-
|
57
|
+
when /^the new project page for the newest account by "([^"]*)"$/
|
58
|
+
user = User.find_by_email!($1)
|
59
|
+
account = user.accounts.order("created_at desc").first
|
59
60
|
new_account_project_path(account)
|
60
61
|
PATHS
|
61
62
|
|
@@ -25,12 +25,8 @@ Factory.define :membership do |f|
|
|
25
25
|
end
|
26
26
|
|
27
27
|
Factory.define :signup do |f|
|
28
|
-
f.account_name { Factory.next(:name) }
|
29
|
-
f.keyword { Factory.next(:name) }
|
30
|
-
f.user_name { "test user" }
|
31
28
|
f.email { Factory.next :email }
|
32
29
|
f.password { "password" }
|
33
|
-
f.password_confirmation { "password" }
|
34
30
|
f.association :plan
|
35
31
|
end
|
36
32
|
|
@@ -8,7 +8,6 @@ Feature: Manage account
|
|
8
8
|
And I am signed in as an admin of the "Test" account
|
9
9
|
When I go to the settings page
|
10
10
|
And I follow "Test"
|
11
|
-
Then I should see "Settings for Test"
|
12
11
|
When I fill in "Account name" with "Name Change"
|
13
12
|
And I press "Update"
|
14
13
|
When I follow "Name Change"
|
@@ -8,41 +8,26 @@ Feature: user adds a new account
|
|
8
8
|
When I go to the sign up page for the "Free" plan
|
9
9
|
And I fill in "Email" with "user@example.com"
|
10
10
|
And I fill in "Password" with "test"
|
11
|
-
And I fill in "Company Name" with "Robots"
|
12
|
-
And I fill in "Keyword" with "robots"
|
13
|
-
And I should see "http://www.example.com/accounts/keyword"
|
14
11
|
And I press "Sign up"
|
15
12
|
Then I should see "created"
|
16
13
|
But I should not see "Instructions for confirming"
|
17
|
-
And I should be on the new project page for the "
|
18
|
-
When I go to the settings page
|
19
|
-
And I follow "Robots"
|
20
|
-
Then the "Keyword" field should contain "robots"
|
14
|
+
And I should be on the new project page for the newest account by "user@example.com"
|
21
15
|
|
22
16
|
Scenario: sign up for two accounts
|
23
17
|
When I go to the sign up page for the "Free" plan
|
24
18
|
And I fill in "Email" with "email@person.com"
|
25
19
|
And I fill in "Password" with "password"
|
26
|
-
And I fill in "Confirm password" with "password"
|
27
|
-
And I fill in "Your name" with "Robot"
|
28
|
-
And I fill in "Company Name" with "Robots, Inc"
|
29
|
-
And I fill in "Keyword" with "robots"
|
30
20
|
And I press "Sign up"
|
31
21
|
Then I should see "created"
|
32
|
-
And I should be on the new project page for the
|
33
|
-
When I go to the settings page
|
34
|
-
And I follow "Robots, Inc"
|
35
|
-
Then the "Keyword" field should contain "robots"
|
22
|
+
And I should be on the new project page for the newest account by "email@person.com"
|
36
23
|
When I go to the settings page
|
24
|
+
Then I should see 1 account
|
37
25
|
And I follow "Add new account"
|
38
26
|
And I follow "Free"
|
39
|
-
|
40
|
-
And I fill in "Keyword" with "machines"
|
27
|
+
Then I should see "Your existing user, email, will be added as the first administrator on this new account."
|
41
28
|
And I press "Sign up"
|
42
29
|
Then I should see "created"
|
43
30
|
But I should not see "Instructions for confirming"
|
44
|
-
And I should be on the new project page for the "
|
31
|
+
And I should be on the new project page for the newest account by "email@person.com"
|
45
32
|
When I go to the settings page
|
46
|
-
|
47
|
-
Then the "Keyword" field should contain "machines"
|
48
|
-
|
33
|
+
Then I should see 2 accounts
|
@@ -19,7 +19,6 @@ Feature: Sign up
|
|
19
19
|
Then I should see "Free"
|
20
20
|
And I fill in "Email" with "invalidemail"
|
21
21
|
And I fill in "Password" with "password"
|
22
|
-
And I fill in "Confirm password" with ""
|
23
22
|
And I should not see "Billing Information"
|
24
23
|
And I press "Sign up"
|
25
24
|
Then the form should have inline error messages
|
@@ -29,9 +28,5 @@ Feature: Sign up
|
|
29
28
|
And I follow "Free"
|
30
29
|
And I fill in "Email" with "email@person.com"
|
31
30
|
And I fill in "Password" with "password"
|
32
|
-
And I fill in "Confirm password" with "password"
|
33
|
-
And I fill in "Your name" with "Robot"
|
34
|
-
And I fill in "Company Name" with "Robots, Inc"
|
35
|
-
And I fill in "Keyword" with "robotsinc"
|
36
31
|
And I press "Sign up"
|
37
32
|
Then I should see "created"
|
@@ -15,7 +15,6 @@ Feature: Sign up
|
|
15
15
|
And the "Verification code" field should have autocomplete off
|
16
16
|
And I fill in "Email" with "invalidemail"
|
17
17
|
And I fill in "Password" with "password"
|
18
|
-
And I fill in "Confirm password" with ""
|
19
18
|
And I should see "Billing Information"
|
20
19
|
And I press "Sign up"
|
21
20
|
Then the form should have inline error messages
|
@@ -26,10 +25,6 @@ Feature: Sign up
|
|
26
25
|
When I follow "Paid"
|
27
26
|
And I fill in "Email" with "email@person.com"
|
28
27
|
And I fill in "Password" with "password"
|
29
|
-
And I fill in "Confirm password" with "password"
|
30
|
-
And I fill in "Your name" with "Robot"
|
31
|
-
And I fill in "Company Name" with "Robots, Inc"
|
32
|
-
And I fill in "Keyword" with "robotsinc"
|
33
28
|
And I fill in "Cardholder name" with "Ralph Robot"
|
34
29
|
And I fill in "Billing email" with "accounting@example.com"
|
35
30
|
And I fill in "Card number" with "4111111111111111"
|
@@ -45,10 +40,6 @@ Feature: Sign up
|
|
45
40
|
And I follow "Paid"
|
46
41
|
And I fill in "Email" with "email@person.com"
|
47
42
|
And I fill in "Password" with "password"
|
48
|
-
And I fill in "Confirm password" with "password"
|
49
|
-
And I fill in "Your name" with "Robot"
|
50
|
-
And I fill in "Company Name" with "Robots, Inc"
|
51
|
-
And I fill in "Keyword" with "robotsinc"
|
52
43
|
And I fill in "Cardholder name" with "Ralph Robot"
|
53
44
|
And I fill in "Billing email" with "accounting@example.com"
|
54
45
|
And I fill in "Card number" with "4111112"
|
@@ -64,10 +55,6 @@ Feature: Sign up
|
|
64
55
|
And I follow "Paid"
|
65
56
|
And I fill in "Email" with "email@person.com"
|
66
57
|
And I fill in "Password" with "password"
|
67
|
-
And I fill in "Confirm password" with "password"
|
68
|
-
And I fill in "Your name" with "Robot"
|
69
|
-
And I fill in "Company Name" with "Robots, Inc"
|
70
|
-
And I fill in "Keyword" with "robotsinc"
|
71
58
|
And I fill in "Cardholder name" with "Ralph Robot"
|
72
59
|
And I fill in "Billing email" with "accounting@example.com"
|
73
60
|
And I fill in "Card number" with "4111111111111111"
|
@@ -19,10 +19,6 @@ Feature: Trial plans
|
|
19
19
|
But I should not see "users"
|
20
20
|
When I fill in "Email" with "email@person.com"
|
21
21
|
And I fill in "Password" with "password"
|
22
|
-
And I fill in "Confirm password" with "password"
|
23
|
-
And I fill in "Your name" with "Robot"
|
24
|
-
And I fill in "Company Name" with "Robots, Inc"
|
25
|
-
And I fill in "Keyword" with "robotsinc"
|
26
22
|
And I press "Sign up"
|
27
23
|
Then I should see "created"
|
28
24
|
|
@@ -73,4 +69,4 @@ Feature: Trial plans
|
|
73
69
|
Then an email with subject "A check in" should be sent to "admin@example.com"
|
74
70
|
When I sign in as "admin@example.com/password"
|
75
71
|
And I follow the link sent to "admin@example.com" with subject "A check in"
|
76
|
-
Then I should be on the new project page for the "
|
72
|
+
Then I should be on the new project page for the newest account by "admin@example.com"
|
@@ -17,3 +17,14 @@ Given /^the following limit exists for the "([^"]*)" account:$/ do |account_name
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
When /^I follow "([^"]*)" for the "([^"]*)" account$/ do |link_text, account_name|
|
22
|
+
account = Account.find_by_name!(account_name)
|
23
|
+
within "##{dom_id(account)}" do
|
24
|
+
click_link link_text
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Then /^I should see (\d+) accounts?$/ do |count|
|
29
|
+
page.all("#user_accounts li").size.should == count.to_i
|
30
|
+
end
|
data/spec/models/signup_spec.rb
CHANGED
@@ -10,11 +10,10 @@ describe Signup do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe Signup, "with attributes in the constructor" do
|
13
|
-
subject { Signup.new(:
|
13
|
+
subject { Signup.new(:email => 'person@example.com', :password => 'password') }
|
14
14
|
it "assigns attributes" do
|
15
|
-
subject.
|
16
|
-
subject.
|
17
|
-
subject.keyword.should == 'blk'
|
15
|
+
subject.email.should == 'person@example.com'
|
16
|
+
subject.password.should == 'password'
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
@@ -22,8 +21,8 @@ describe Signup, "with nil to the constructor" do
|
|
22
21
|
subject { Signup.new(nil) }
|
23
22
|
|
24
23
|
it "assigns no attributes" do
|
25
|
-
subject.
|
26
|
-
subject.
|
24
|
+
subject.email.should be_blank
|
25
|
+
subject.password.should be_blank
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
@@ -73,45 +72,36 @@ describe Signup, "with a valid user and account" do
|
|
73
72
|
it "creates an admin user" do
|
74
73
|
subject.user.should be_admin_of(subject.account)
|
75
74
|
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe Signup, "with a valid user but invalid account" do
|
79
|
-
it_should_behave_like "invalid signup"
|
80
|
-
subject { Factory.build(:signup, :account_name => "") }
|
81
75
|
|
82
|
-
|
83
|
-
|
76
|
+
it "gives a friendly account name" do
|
77
|
+
subject.account.name.should == "user"
|
84
78
|
end
|
85
79
|
|
86
|
-
it "
|
87
|
-
subject.
|
80
|
+
it "gives a friendly account keyword" do
|
81
|
+
p subject.account
|
82
|
+
subject.account.keyword.should =~ /^user.+/
|
88
83
|
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe Signup, "with an invalid user but valid account" do
|
92
|
-
subject { Factory.build(:signup, :user_name => nil) }
|
93
|
-
it_should_behave_like "invalid signup"
|
94
84
|
|
95
|
-
|
96
|
-
|
85
|
+
it "gives it's account a name and keyword" do
|
86
|
+
subject.account.name.should_not be_blank
|
87
|
+
subject.account.keyword.should_not be_blank
|
97
88
|
end
|
98
89
|
|
99
|
-
it "
|
100
|
-
subject.
|
90
|
+
it "gives it's user a name that is the first part of it's email" do
|
91
|
+
subject.user.name.should == "user"
|
101
92
|
end
|
102
93
|
end
|
103
94
|
|
104
|
-
describe Signup, "with an invalid user
|
105
|
-
subject { Factory.build(:signup, :
|
95
|
+
describe Signup, "with an invalid user" do
|
96
|
+
subject { Factory.build(:signup, :email => nil) }
|
106
97
|
it_should_behave_like "invalid signup"
|
107
98
|
|
108
99
|
before do
|
109
100
|
@result = subject.save
|
110
101
|
end
|
111
102
|
|
112
|
-
it "adds error messages
|
113
|
-
subject.errors[:
|
114
|
-
subject.errors[:account_name].should_not be_empty
|
103
|
+
it "adds error messages" do
|
104
|
+
subject.errors[:email].should_not be_empty
|
115
105
|
end
|
116
106
|
end
|
117
107
|
|
@@ -166,23 +156,6 @@ describe Signup, "valid with an existing user and incorrect password" do
|
|
166
156
|
end
|
167
157
|
end
|
168
158
|
|
169
|
-
describe Signup, "invalid with an existing user and correct password" do
|
170
|
-
it_should_behave_like "invalid signup"
|
171
|
-
let(:email) { "user@example.com" }
|
172
|
-
let(:password) { "test" }
|
173
|
-
let!(:user) { Factory(:user, :email => email,
|
174
|
-
:password => password,
|
175
|
-
:password_confirmation => password) }
|
176
|
-
subject { Factory.build(:signup, :account_name => '',
|
177
|
-
:email => email,
|
178
|
-
:password => password) }
|
179
|
-
before { @result = subject.save }
|
180
|
-
|
181
|
-
it "doesn't assign the user to the account" do
|
182
|
-
user.reload.accounts.should_not include(subject.account)
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
159
|
describe Signup, "with an account that doesn't save" do
|
187
160
|
subject { Factory.build(:signup) }
|
188
161
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saucy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 2
|
10
|
+
version: 0.5.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- thoughtbot, inc.
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-04-
|
21
|
+
date: 2011-04-27 00:00:00 -04:00
|
22
22
|
default_executable:
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|