tournament 3.0.3 → 3.1.0

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.
Files changed (38) hide show
  1. data/History.txt +5 -0
  2. data/lib/tournament/bracket.rb +9 -5
  3. data/lib/tournament/pool.rb +15 -10
  4. data/lib/tournament.rb +1 -1
  5. data/webgui/app/controllers/reports_controller.rb +10 -4
  6. data/webgui/app/controllers/users_controller.rb +61 -0
  7. data/webgui/app/models/user.rb +31 -3
  8. data/webgui/app/models/user_mailer.rb +7 -0
  9. data/webgui/app/views/sessions/new.html.erb +2 -0
  10. data/webgui/app/views/user_mailer/password_reset_notification.erb +7 -0
  11. data/webgui/app/views/users/lost_password.html.erb +20 -0
  12. data/webgui/app/views/users/reset_password.html.erb +15 -0
  13. data/webgui/config/environments/development.rb +1 -1
  14. data/webgui/config/routes.rb +8 -6
  15. data/webgui/db/migrate/20100312053540_add_password_reset_code.rb +9 -0
  16. data/webgui/db/schema.rb +92 -0
  17. data/webgui/doc/README_FOR_APP +47 -4
  18. data/webgui/lib/tasks/possibility.rake +1 -1
  19. data/webgui/vendor/plugins/restful_authentication/LICENSE +20 -0
  20. data/webgui/vendor/plugins/restful_authentication/README.textile +25 -25
  21. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/authenticated_generator.rb +19 -19
  22. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/authenticated_test_helper.rb +1 -1
  23. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/features/accounts.feature +109 -0
  24. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/{stories/users/sessions.story → features/sessions.feature} +44 -44
  25. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/features/step_definitions/ra_env.rb +9 -0
  26. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/features/step_definitions/ra_navigation_steps.rb +48 -0
  27. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/features/step_definitions/ra_resource_steps.rb +178 -0
  28. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/features/step_definitions/ra_response_steps.rb +169 -0
  29. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/{stories/rest_auth_stories_helper.rb → features/step_definitions/rest_auth_features_helper.rb} +5 -5
  30. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/features/step_definitions/user_steps.rb +131 -0
  31. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/model.rb +2 -2
  32. metadata +17 -11
  33. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/rest_auth_stories.rb +0 -22
  34. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_navigation_steps.rb +0 -49
  35. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_resource_steps.rb +0 -179
  36. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/ra_response_steps.rb +0 -171
  37. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/steps/user_steps.rb +0 -153
  38. data/webgui/vendor/plugins/restful_authentication/generators/authenticated/templates/stories/users/accounts.story +0 -186
@@ -1,179 +0,0 @@
1
- # The flexible code for resource testing came out of code from Ben Mabey
2
- # http://www.benmabey.com/2008/02/04/rspec-plain-text-stories-webrat-chunky-bacon/
3
- steps_for(:ra_resource) do
4
- #
5
- # Construct resources
6
- #
7
-
8
- #
9
- # Build a resource as described, store it as an @instance variable. Ex:
10
- # "Given a <%= file_name %> with login: 'mojojojo'"
11
- # produces a <%= class_name %> instance stored in @<%= file_name %> with 'mojojojo' as its login
12
- # attribute.
13
- #
14
- Given "a $resource instance with $attributes" do |resource, attributes|
15
- klass, instance, attributes = parse_resource_args resource, attributes
16
- instance = klass.new(attributes)
17
- instance.save!
18
- find_resource(resource, attributes).should_not be_nil
19
- keep_instance! resource, instance
20
- end
21
-
22
- #
23
- # Stuff attributes into a preexisting @resource
24
- # "And the <%= file_name %> has thac0: 3"
25
- # takes the earlier-defined @<%= file_name %> instance and sets its thac0 to '3'.
26
- #
27
- Given "the $resource has $attributes" do |resource, attributes|
28
- klass, instance, attributes = parse_resource_args resource, attributes
29
- attributes.each do |attr, val|
30
- instance.send("#{attr}=", val)
31
- end
32
- instance.save!
33
- find_resource(resource, attributes).should_not be_nil
34
- keep_instance! resource, instance
35
- end
36
-
37
- #
38
- # Destroy all for this resource
39
- #
40
- Given "no $resource with $attr: '$val' exists" do |resource, attr, val|
41
- klass, instance = parse_resource_args resource
42
- klass.destroy_all(attr.to_sym => val)
43
- instance = find_resource resource, attr.to_sym => val
44
- instance.should be_nil
45
- keep_instance! resource, instance
46
- end
47
-
48
- #
49
- # Then's for resources
50
- #
51
-
52
- # Resource like this DOES exist
53
- Then %r{an? $resource with $attributes should exist} do |resource, attributes|
54
- instance = find_resource resource, attributes
55
- instance.should_not be_nil
56
- keep_instance! resource, instance
57
- end
58
- # Resource like this DOES NOT exist
59
- Then %r{no $resource with $attributes should exist} do |resource, attributes|
60
- instance = find_resource resource, attributes
61
- instance.should be_nil
62
- end
63
-
64
- # Resource has attributes with given values
65
- Then "the $resource should have $attributes" do |resource, attributes|
66
- klass, instance, attributes = parse_resource_args resource, attributes
67
- attributes.each do |attr, val|
68
- instance.send(attr).should == val
69
- end
70
- end
71
- # Resource attributes should / should not be nil
72
- Then "the $resource's $attr should be nil" do |resource, attr|
73
- klass, instance = parse_resource_args resource
74
- instance.send(attr).should be_nil
75
- end
76
- Then "the $resource's $attr should not be nil" do |resource, attr|
77
- klass, instance = parse_resource_args resource
78
- instance.send(attr).should_not be_nil
79
- end
80
-
81
- #
82
- # Bank each of the @resource's listed attributes for later.
83
- #
84
- Given "we try hard to remember the $resource's $attributes" do |resource, attributes|
85
- attributes = attributes.to_array_from_story
86
- attributes.each do |attr|
87
- memorize_resource_value resource, attr
88
- end
89
- end
90
- #
91
- # Bank each of the @resource's listed attributes for later.
92
- #
93
- Given "we don't remember anything about the past" do
94
- memorize_forget_all!
95
- end
96
-
97
- #
98
- # Compare @resource.attr to its earlier-memorized value.
99
- # Specify ' using method_name' (abs, to_s, &c) to coerce before comparing.
100
- # For important and mysterious reasons, timestamps want to_i or to_s.
101
- #
102
- Then %r{the $resource\'s $attribute should stay the same(?: under $func)?} do |resource, attr, func|
103
- klass, instance = parse_resource_args resource
104
- # Get the values
105
- old_value = recall_resource_value(resource, attr)
106
- new_value = instance.send(attr)
107
- # Transform each value, maybe, using value.func
108
- if func then new_value = new_value.send(func); old_value = old_value.send(func) end
109
- # Compare
110
- old_value.should eql(new_value)
111
- end
112
-
113
- #
114
- # Look for each for the given attributes in the page's text
115
- #
116
- Then "page should have the $resource's $attributes" do |resource, attributes|
117
- actual_resource = instantize(resource)
118
- attributes.split(/, and |, /).each do |attribute|
119
- response.should have_text(/#{actual_resource.send(attribute.strip.gsub(" ","_"))}/)
120
- end
121
- end
122
-
123
- end
124
-
125
- #
126
- # Turn a resource name and a to_hash_from_story string like
127
- # "attr: 'value', attr2: 'value2', ... , and attrN: 'valueN'"
128
- # into
129
- # * klass -- the class matching that Resource
130
- # * instance -- the possibly-preexisting local instance value @resource
131
- # * attributes -- a hash matching the given attribute-list string
132
- #
133
- def parse_resource_args resource, attributes=nil
134
- instance = instantize resource
135
- klass = resource.classify.constantize
136
- attributes = attributes.to_hash_from_story if attributes
137
- [klass, instance, attributes]
138
- end
139
-
140
- #
141
- # Given a class name 'resource' and a hash of conditsion, find a model
142
- #
143
- def find_resource resource, conditions
144
- klass, instance = parse_resource_args resource
145
- conditions = conditions.to_hash_from_story unless (conditions.is_a? Hash)
146
- klass.find(:first, :conditions => conditions)
147
- end
148
-
149
- #
150
- # Simple, brittle, useful: store the given resource's attribute
151
- # so we can compare it later.
152
- #
153
- def memorize_resource_value resource, attr
154
- klass, instance = parse_resource_args resource
155
- value = instance.send(attr)
156
- @_memorized ||= {}
157
- @_memorized[resource] ||= {}
158
- @_memorized[resource][attr] = value
159
- value
160
- end
161
- def recall_resource_value resource, attr
162
- @_memorized[resource][attr]
163
- end
164
- def memorize_forget_all!
165
- @_memorized = {}
166
- end
167
-
168
- #
169
- # Keep the object around in a local instance variable @resource.
170
- #
171
- # So, for instance,
172
- # klass, instance = parse_resource_args '<%= file_name %>'
173
- # instance = klass.new({login => 'me', password => 'monkey', ...})
174
- # keep_instance! resource, instance
175
- # keeps the just-constructed <%= class_name %> model in the @<%= file_name %> instance variable.
176
- #
177
- def keep_instance! resource, object
178
- instance_variable_set("@#{resource}", object)
179
- end
@@ -1,171 +0,0 @@
1
- #
2
- # What you should see when you get there
3
- #
4
-
5
- steps_for(:ra_response) do
6
- #
7
- # Destinations. Ex:
8
- # She should be at the new kids page
9
- # Tarkin should be at the destroy alderaan page
10
- # The visitor should be at the '/lolcats/download' form
11
- # The visitor should be redirected to '/hi/mom'
12
- #
13
- # It doesn't know anything about actual routes -- it just
14
- # feeds its output to render_template or redirect_to
15
- #
16
- Then "$actor should be at $path" do |_, path|
17
- response.should render_template(grok_path(path))
18
- end
19
-
20
- Then "$actor should be redirected to $path" do |_, path|
21
- response.should redirect_to(grok_path(path))
22
- end
23
-
24
- Then "the page should look AWESOME" do
25
- response.should have_tag('head>title')
26
- response.should have_tag('h1')
27
- # response.should be_valid_xhtml
28
- end
29
-
30
- #
31
- # Tags
32
- #
33
-
34
- Then "the page should contain '$text'" do |_, text|
35
- response.should have_text(/#{text}/)
36
- end
37
-
38
- # please note: this enforces the use of a <label> field
39
- Then "$actor should see a <$container> containing a $attributes" do |_, container, attributes|
40
- attributes = attributes.to_hash_from_story
41
- response.should have_tag(container) do
42
- attributes.each do |tag, label|
43
- case tag
44
- when "textfield" then with_tag "input[type='text']"; with_tag("label", label)
45
- when "password" then with_tag "input[type='password']"; with_tag("label", label)
46
- when "submit" then with_tag "input[type='submit'][value='#{label}']"
47
- else with_tag tag, label
48
- end
49
- end
50
- end
51
- end
52
-
53
- #
54
- # Session, cookie variables
55
- #
56
- Then "$actor $token cookie should include $attrlist" do |_, token, attrlist|
57
- attrlist = attrlist.to_array_from_story
58
- cookies.include?(token).should be_true
59
- attrlist.each do |val|
60
- cookies[token].include?(val).should be_true
61
- end
62
- end
63
-
64
- Then "$actor $token cookie should exist but not include $attrlist" do |_, token, attrlist|
65
- attrlist = attrlist.to_array_from_story
66
- cookies.include?(token).should be_true
67
- puts [cookies, attrlist, token].to_yaml
68
- attrlist.each do |val|
69
- cookies[token].include?(val).should_not be_true
70
- end
71
- end
72
-
73
- Then "$actor should have $an $token cookie" do |_, _, token|
74
- cookies[token].should_not be_blank
75
- end
76
- Then "$actor should not have $an $token cookie" do |_, _, token|
77
- cookies[token].should be_blank
78
- end
79
-
80
- Given "$actor has $an cookie jar with $attributes" do |_, _, attributes|
81
- attributes = attributes.to_hash_from_story
82
- attributes.each do |attr, val|
83
- cookies[attr] = val
84
- end
85
- end
86
- Given "$actor session store has no $attrlist" do |_, attrlist|
87
- attrlist = attrlist.to_array_from_story
88
- attrlist.each do |attr|
89
- # Note that the comparison passes through 'to_s'
90
- session[attr.to_sym] = nil
91
- end
92
- end
93
-
94
- Then "$actor session store should have $attributes" do |_, attributes|
95
- attributes = attributes.to_hash_from_story
96
- attributes.each do |attr, val|
97
- # Note that the comparison passes through 'to_s'
98
- session[attr.to_sym].to_s.should eql(val)
99
- end
100
- end
101
-
102
- Then "$actor session store should not have $attrlist" do |_, attrlist|
103
- attrlist = attrlist.to_array_from_story
104
- attrlist.each do |attr|
105
- session[attr.to_sym].blank?.should be_true
106
- end
107
- end
108
-
109
- #
110
- # Flash messages
111
- #
112
-
113
- Then "$actor should see $an $notice message '$message'" do |_, _, notice, message|
114
- response.should have_flash(notice, %r{#{message}})
115
- end
116
-
117
- Then "$actor should not see $an $notice message '$message'" do |_, _, notice, message|
118
- response.should_not have_flash(notice, %r{#{message}})
119
- end
120
-
121
- Then "$actor should see no messages" do |_|
122
- ['error', 'warning', 'notice'].each do |notice|
123
- response.should_not have_flash(notice)
124
- end
125
- end
126
-
127
- RE_POLITENESS = /(?:please|sorry|thank(?:s| you))/i
128
- Then %r{we should be polite about it} do
129
- response.should have_tag("div.error,div.notice", RE_POLITENESS)
130
- end
131
- Then %r{we should not even be polite about it} do
132
- response.should_not have_tag("div.error,div.notice", RE_POLITENESS)
133
- end
134
-
135
- #
136
- # Resource's attributes
137
- #
138
- # "Then page should have the $resource's $attributes" is in resource_steps
139
-
140
- # helpful debug step
141
- Then "we dump the response" do
142
- dump_response
143
- end
144
- end
145
-
146
-
147
- def have_flash notice, *args
148
- have_tag("div.#{notice}", *args)
149
- end
150
-
151
- RE_PRETTY_RESOURCE = /the (index|show|new|create|edit|update|destroy) (\w+) (page|form)/i
152
- RE_THE_FOO_PAGE = /the '?([^']*)'? (page|form)/i
153
- RE_QUOTED_PATH = /^'([^']*)'$/i
154
- def grok_path path
155
- path.gsub(/\s+again$/,'') # strip trailing ' again'
156
- case
157
- when path == 'the home page' then dest = '/'
158
- when path =~ RE_PRETTY_RESOURCE then dest = template_for $1, $2
159
- when path =~ RE_THE_FOO_PAGE then dest = $1
160
- when path =~ RE_QUOTED_PATH then dest = $1
161
- else dest = path
162
- end
163
- dest
164
- end
165
-
166
- # turns 'new', 'road bikes' into 'road_bikes/new'
167
- # note that it's "action resource"
168
- def template_for(action, resource)
169
- "#{resource.gsub(" ","_")}/#{action}"
170
- end
171
-
@@ -1,153 +0,0 @@
1
- require File.dirname(__FILE__) + '/../helper'
2
-
3
- RE_<%= file_name.capitalize %> = %r{(?:(?:the )? *(\w+) *)}
4
- RE_<%= file_name.capitalize %>_TYPE = %r{(?: *(\w+)? *)}
5
- steps_for(:<%= file_name %>) do
6
-
7
- #
8
- # Setting
9
- #
10
-
11
- Given "an anonymous <%= file_name %>" do
12
- log_out!
13
- end
14
-
15
- Given "$an $<%= file_name %>_type <%= file_name %> with $attributes" do |_, <%= file_name %>_type, attributes|
16
- create_<%= file_name %>! <%= file_name %>_type, attributes.to_hash_from_story
17
- end
18
-
19
- Given "$an $<%= file_name %>_type <%= file_name %> named '$login'" do |_, <%= file_name %>_type, login|
20
- create_<%= file_name %>! <%= file_name %>_type, named_<%= file_name %>(login)
21
- end
22
-
23
- Given "$an $<%= file_name %>_type <%= file_name %> logged in as '$login'" do |_, <%= file_name %>_type, login|
24
- create_<%= file_name %>! <%= file_name %>_type, named_<%= file_name %>(login)
25
- log_in_<%= file_name %>!
26
- end
27
-
28
- Given "$actor is logged in" do |_, login|
29
- log_in_<%= file_name %>! @<%= file_name %>_params || named_<%= file_name %>(login)
30
- end
31
-
32
- Given "there is no $<%= file_name %>_type <%= file_name %> named '$login'" do |_, login|
33
- @<%= file_name %> = <%= class_name %>.find_by_login(login)
34
- @<%= file_name %>.destroy! if @<%= file_name %>
35
- @<%= file_name %>.should be_nil
36
- end
37
-
38
- #
39
- # Actions
40
- #
41
- When "$actor logs out" do
42
- log_out
43
- end
44
-
45
- When "$actor registers an account as the preloaded '$login'" do |_, login|
46
- <%= file_name %> = named_<%= file_name %>(login)
47
- <%= file_name %>['password_confirmation'] = <%= file_name %>['password']
48
- create_<%= file_name %> <%= file_name %>
49
- end
50
-
51
- When "$actor registers an account with $attributes" do |_, attributes|
52
- create_<%= file_name %> attributes.to_hash_from_story
53
- end
54
- <% if options[:include_activation] %>
55
- When "$actor activates with activation code $attributes" do |_, activation_code|
56
- activation_code = '' if activation_code == 'that is blank'
57
- activate
58
- end<% end %>
59
-
60
- When "$actor logs in with $attributes" do |_, attributes|
61
- log_in_<%= file_name %> attributes.to_hash_from_story
62
- end
63
-
64
- #
65
- # Result
66
- #
67
- Then "$actor should be invited to sign in" do |_|
68
- response.should render_template('/<%= controller_file_path %>/new')
69
- end
70
-
71
- Then "$actor should not be logged in" do |_|
72
- controller.logged_in?.should_not be_true
73
- end
74
-
75
- Then "$login should be logged in" do |login|
76
- controller.logged_in?.should be_true
77
- controller.current_<%= file_name %>.should === @<%= file_name %>
78
- controller.current_<%= file_name %>.login.should == login
79
- end
80
-
81
- end
82
-
83
- def named_<%= file_name %> login
84
- <%= file_name %>_params = {
85
- 'admin' => {'id' => 1, 'login' => 'addie', 'password' => '1234addie', 'email' => 'admin@example.com', },
86
- 'oona' => { 'login' => 'oona', 'password' => '1234oona', 'email' => 'unactivated@example.com'},
87
- 'reggie' => { 'login' => 'reggie', 'password' => 'monkey', 'email' => 'registered@example.com' },
88
- }
89
- <%= file_name %>_params[login.downcase]
90
- end
91
-
92
- #
93
- # <%= class_name %> account actions.
94
- #
95
- # The ! methods are 'just get the job done'. It's true, they do some testing of
96
- # their own -- thus un-DRY'ing tests that do and should live in the <%= file_name %> account
97
- # stories -- but the repetition is ultimately important so that a faulty test setup
98
- # fails early.
99
- #
100
-
101
- def log_out
102
- get '/<%= controller_file_path %>/destroy'
103
- end
104
-
105
- def log_out!
106
- log_out
107
- response.should redirect_to('/')
108
- follow_redirect!
109
- end
110
-
111
- def create_<%= file_name %>(<%= file_name %>_params={})
112
- @<%= file_name %>_params ||= <%= file_name %>_params
113
- post "/<%= model_controller_file_path %>", :<%= file_name %> => <%= file_name %>_params
114
- @<%= file_name %> = <%= class_name %>.find_by_login(<%= file_name %>_params['login'])
115
- end
116
-
117
- def create_<%= file_name %>!(<%= file_name %>_type, <%= file_name %>_params)
118
- <%= file_name %>_params['password_confirmation'] ||= <%= file_name %>_params['password'] ||= <%= file_name %>_params['password']
119
- create_<%= file_name %> <%= file_name %>_params
120
- response.should redirect_to('/')
121
- follow_redirect!
122
- <% if options[:include_activation] %>
123
- # fix the <%= file_name %>'s activation status
124
- activate_<%= file_name %>! if <%= file_name %>_type == 'activated'<% end %>
125
- end
126
-
127
- <% if options[:include_activation] %>
128
- def activate_<%= file_name %> activation_code=nil
129
- activation_code = @<%= file_name %>.activation_code if activation_code.nil?
130
- get "/activate/#{activation_code}"
131
- end
132
-
133
- def activate_<%= file_name %>! *args
134
- activate_<%= file_name %> *args
135
- response.should redirect_to('/login')
136
- follow_redirect!
137
- response.should have_flash("notice", /Signup complete!/)
138
- end<% end %>
139
-
140
- def log_in_<%= file_name %> <%= file_name %>_params=nil
141
- @<%= file_name %>_params ||= <%= file_name %>_params
142
- <%= file_name %>_params ||= @<%= file_name %>_params
143
- post "/<%= controller_routing_path %>", <%= file_name %>_params
144
- @<%= file_name %> = <%= class_name %>.find_by_login(<%= file_name %>_params['login'])
145
- controller.current_<%= file_name %>
146
- end
147
-
148
- def log_in_<%= file_name %>! *args
149
- log_in_<%= file_name %> *args
150
- response.should redirect_to('/')
151
- follow_redirect!
152
- response.should have_flash("notice", /Logged in successfully/)
153
- end
@@ -1,186 +0,0 @@
1
- Visitors should be in control of creating an account and of proving their
2
- essential humanity/accountability or whatever it is people think the
3
- id-validation does. We should be fairly skeptical about this process, as the
4
- identity+trust chain starts here.
5
-
6
- Story: Creating an account
7
- As an anonymous <%= file_name %>
8
- I want to be able to create an account
9
- So that I can be one of the cool kids
10
-
11
- #
12
- # Account Creation: Get entry form
13
- #
14
- Scenario: Anonymous <%= file_name %> can start creating an account
15
- Given an anonymous <%= file_name %>
16
- When she goes to /signup
17
- Then she should be at the '<%= model_controller_routing_path %>/new' page
18
- And the page should look AWESOME
19
- And she should see a <form> containing a textfield: Login, textfield: Email, password: Password, password: 'Confirm Password', submit: 'Sign up'
20
-
21
- #
22
- # Account Creation
23
- #
24
- Scenario: Anonymous <%= file_name %> can create an account
25
- Given an anonymous <%= file_name %>
26
- And no <%= file_name %> with login: 'Oona' exists
27
- When she registers an account as the preloaded 'Oona'
28
- Then she should be redirected to the home page
29
- When she follows that redirect!
30
- Then she should see a notice message 'Thanks for signing up!'
31
- And a <%= file_name %> with login: 'oona' should exist
32
- And the <%= file_name %> should have login: 'oona', and email: 'unactivated@example.com'
33
- <% if options[:include_activation] %>
34
- And the <%= file_name %>'s activation_code should not be nil
35
- And the <%= file_name %>'s activated_at should be nil
36
- And she should not be logged in
37
- <% else %>
38
- And oona should be logged in
39
- <% end %>
40
-
41
- #
42
- # Account Creation Failure: Account exists
43
- #
44
- <% if options[:include_activation] %>
45
- Scenario: Anonymous <%= file_name %> can not create an account replacing a non-activated account
46
- Given an anonymous <%= file_name %>
47
- And a registered <%= file_name %> named 'Reggie'
48
- And the <%= file_name %> has activation_code: 'activate_me', activated_at: nil!
49
- And we try hard to remember the <%= file_name %>'s updated_at, and created_at
50
- When she registers an account with login: 'reggie', password: 'monkey', and email: 'different@example.com'
51
- Then she should be at the '<%= model_controller_routing_path %>/new' page
52
- And she should see an errorExplanation message 'Login has already been taken'
53
- And she should not see an errorExplanation message 'Email has already been taken'
54
- And a <%= file_name %> with login: 'reggie' should exist
55
- And the <%= file_name %> should have email: 'registered@example.com'
56
- And the <%= file_name %>'s activation_code should not be nil
57
- And the <%= file_name %>'s activated_at should be nil
58
- And the <%= file_name %>'s created_at should stay the same under to_s
59
- And the <%= file_name %>'s updated_at should stay the same under to_s
60
- And she should not be logged in<% end %>
61
-
62
- Scenario: Anonymous <%= file_name %> can not create an account replacing an activated account
63
- Given an anonymous <%= file_name %>
64
- And an activated <%= file_name %> named 'Reggie'
65
- And we try hard to remember the <%= file_name %>'s updated_at, and created_at
66
- When she registers an account with login: 'reggie', password: 'monkey', and email: 'reggie@example.com'
67
- Then she should be at the '<%= model_controller_routing_path %>/new' page
68
- And she should see an errorExplanation message 'Login has already been taken'
69
- And she should not see an errorExplanation message 'Email has already been taken'
70
- And a <%= file_name %> with login: 'reggie' should exist
71
- And the <%= file_name %> should have email: 'registered@example.com'
72
- <% if options[:include_activation] %>
73
- And the <%= file_name %>'s activation_code should be nil
74
- And the <%= file_name %>'s activated_at should not be nil<% end %>
75
- And the <%= file_name %>'s created_at should stay the same under to_s
76
- And the <%= file_name %>'s updated_at should stay the same under to_s
77
- And she should not be logged in
78
-
79
- #
80
- # Account Creation Failure: Incomplete input
81
- #
82
- Scenario: Anonymous <%= file_name %> can not create an account with incomplete or incorrect input
83
- Given an anonymous <%= file_name %>
84
- And no <%= file_name %> with login: 'Oona' exists
85
- When she registers an account with login: '', password: 'monkey', password_confirmation: 'monkey' and email: 'unactivated@example.com'
86
- Then she should be at the '<%= model_controller_routing_path %>/new' page
87
- And she should see an errorExplanation message 'Login can't be blank'
88
- And no <%= file_name %> with login: 'oona' should exist
89
-
90
- Scenario: Anonymous <%= file_name %> can not create an account with no password
91
- Given an anonymous <%= file_name %>
92
- And no <%= file_name %> with login: 'Oona' exists
93
- When she registers an account with login: 'oona', password: '', password_confirmation: 'monkey' and email: 'unactivated@example.com'
94
- Then she should be at the '<%= model_controller_routing_path %>/new' page
95
- And she should see an errorExplanation message 'Password can't be blank'
96
- And no <%= file_name %> with login: 'oona' should exist
97
-
98
- Scenario: Anonymous <%= file_name %> can not create an account with no password_confirmation
99
- Given an anonymous <%= file_name %>
100
- And no <%= file_name %> with login: 'Oona' exists
101
- When she registers an account with login: 'oona', password: 'monkey', password_confirmation: '' and email: 'unactivated@example.com'
102
- Then she should be at the '<%= model_controller_routing_path %>/new' page
103
- And she should see an errorExplanation message 'Password confirmation can't be blank'
104
- And no <%= file_name %> with login: 'oona' should exist
105
-
106
- Scenario: Anonymous <%= file_name %> can not create an account with mismatched password & password_confirmation
107
- Given an anonymous <%= file_name %>
108
- And no <%= file_name %> with login: 'Oona' exists
109
- When she registers an account with login: 'oona', password: 'monkey', password_confirmation: 'monkeY' and email: 'unactivated@example.com'
110
- Then she should be at the '<%= model_controller_routing_path %>/new' page
111
- And she should see an errorExplanation message 'Password doesn't match confirmation'
112
- And no <%= file_name %> with login: 'oona' should exist
113
-
114
- Scenario: Anonymous <%= file_name %> can not create an account with bad email
115
- Given an anonymous <%= file_name %>
116
- And no <%= file_name %> with login: 'Oona' exists
117
- When she registers an account with login: 'oona', password: 'monkey', password_confirmation: 'monkey' and email: ''
118
- Then she should be at the '<%= model_controller_routing_path %>/new' page
119
- And she should see an errorExplanation message 'Email can't be blank'
120
- And no <%= file_name %> with login: 'oona' should exist
121
- When she registers an account with login: 'oona', password: 'monkey', password_confirmation: 'monkey' and email: 'unactivated@example.com'
122
- Then she should be redirected to the home page
123
- When she follows that redirect!
124
- Then she should see a notice message 'Thanks for signing up!'
125
- And a <%= file_name %> with login: 'oona' should exist
126
- And the <%= file_name %> should have login: 'oona', and email: 'unactivated@example.com'
127
- <% if options[:include_activation] %>
128
- And the <%= file_name %>'s activation_code should not be nil
129
- And the <%= file_name %>'s activated_at should be nil
130
- And she should not be logged in
131
- <% else %>
132
- And oona should be logged in
133
- <% end %>
134
-
135
- <% if options[:include_activation] %>
136
- Story: Activating an account
137
- As a registered, but not yet activated, <%= file_name %>
138
- I want to be able to activate my account
139
- So that I can log in to the site
140
-
141
- #
142
- # Successful activation
143
- #
144
- Scenario: Not-yet-activated <%= file_name %> can activate her account
145
- Given a registered <%= file_name %> named 'Reggie'
146
- And the <%= file_name %> has activation_code: 'activate_me', activated_at: nil!
147
- And we try hard to remember the <%= file_name %>'s updated_at, and created_at
148
- When she goes to /activate/activate_me
149
- Then she should be redirected to 'login'
150
- When she follows that redirect!
151
- Then she should see a notice message 'Signup complete!'
152
- And a <%= file_name %> with login: 'reggie' should exist
153
- And the <%= file_name %> should have login: 'reggie', and email: 'registered@example.com'
154
- And the <%= file_name %>'s activation_code should be nil
155
- And the <%= file_name %>'s activated_at should not be nil
156
- And she should not be logged in
157
-
158
- #
159
- # Unsuccessful activation
160
- #
161
- Scenario: Not-yet-activated <%= file_name %> can't activate her account with a blank activation code
162
- Given a registered <%= file_name %> named 'Reggie'
163
- And the <%= file_name %> has activation_code: 'activate_me', activated_at: nil!
164
- And we try hard to remember the <%= file_name %>'s updated_at, and created_at
165
- When she goes to /activate/
166
- Then she should be redirected to the home page
167
- When she follows that redirect!
168
- Then she should see an error message 'activation code was missing'
169
- And a <%= file_name %> with login: 'reggie' should exist
170
- And the <%= file_name %> should have login: 'reggie', activation_code: 'activate_me', and activated_at: nil!
171
- And the <%= file_name %>'s updated_at should stay the same under to_s
172
- And she should not be logged in
173
-
174
- Scenario: Not-yet-activated <%= file_name %> can't activate her account with a bogus activation code
175
- Given a registered <%= file_name %> named 'Reggie'
176
- And the <%= file_name %> has activation_code: 'activate_me', activated_at: nil!
177
- And we try hard to remember the <%= file_name %>'s updated_at, and created_at
178
- When she goes to /activate/i_haxxor_joo
179
- Then she should be redirected to the home page
180
- When she follows that redirect!
181
- Then she should see an error message 'couldn\'t find a <%= file_name %> with that activation code'
182
- And a <%= file_name %> with login: 'reggie' should exist
183
- And the <%= file_name %> should have login: 'reggie', activation_code: 'activate_me', and activated_at: nil!
184
- And the <%= file_name %>'s updated_at should stay the same under to_s
185
- And she should not be logged in
186
- <% end %>