branston 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/branston/Gemfile +25 -0
  3. data/lib/branston/Gemfile.lock +76 -0
  4. data/lib/branston/app/controllers/application_controller.rb +1 -1
  5. data/lib/branston/app/controllers/outcomes_controller.rb +2 -0
  6. data/lib/branston/app/controllers/stories_controller.rb +82 -86
  7. data/lib/branston/app/controllers/users_controller.rb +69 -11
  8. data/lib/branston/app/helpers/iterations_helper.rb +13 -13
  9. data/lib/branston/app/models/iteration.rb +3 -1
  10. data/lib/branston/app/models/release.rb +0 -1
  11. data/lib/branston/app/models/story.rb +30 -28
  12. data/lib/branston/app/models/user.rb +46 -1
  13. data/lib/branston/app/views/layouts/_header.html.erb +8 -3
  14. data/lib/branston/app/views/layouts/user_roles.html.erb +5 -5
  15. data/lib/branston/app/views/sessions/new.html.erb +8 -14
  16. data/lib/branston/app/views/users/_admin_controls.html.erb +14 -0
  17. data/lib/branston/app/views/users/_form.html.erb +27 -0
  18. data/lib/branston/app/views/users/edit.html.erb +9 -0
  19. data/lib/branston/app/views/users/index.html.erb +14 -0
  20. data/lib/branston/app/views/users/new.html.erb +3 -22
  21. data/lib/branston/config/boot.rb +20 -0
  22. data/lib/branston/config/environment.rb +2 -7
  23. data/lib/branston/config/environments/test.rb +0 -8
  24. data/lib/branston/config/preinitializer.rb +21 -0
  25. data/lib/branston/config/routes.rb +15 -10
  26. data/lib/branston/db/development.sqlite3 +0 -0
  27. data/lib/branston/db/development_structure.sql +21 -8
  28. data/lib/branston/db/migrate/20100723161424_add_state_to_user.rb +12 -0
  29. data/lib/branston/db/migrate/20100726150322_add_activation_fields_to_user.rb +12 -0
  30. data/lib/branston/db/migrate/20100729125551_set_default_user_state_to_pending.rb +10 -0
  31. data/lib/branston/db/migrate/20100812133837_add_is_admin_property_to_user.rb +10 -0
  32. data/lib/branston/db/migrate/20100812140532_set_default_user_state_to_active.rb +10 -0
  33. data/lib/branston/db/migrate/20100812143455_add_default_admin_user.rb +17 -0
  34. data/lib/branston/db/migrate/20110408162438_remove_is_admin_property_and_add_role_instead.rb +12 -0
  35. data/lib/branston/db/pristine.sqlite3 +0 -0
  36. data/lib/branston/db/schema.rb +6 -8
  37. data/lib/branston/db/test.sqlite3 +0 -0
  38. data/lib/branston/log/development.log +1181 -433
  39. data/lib/branston/log/test.log +145306 -52026
  40. data/lib/branston/test/blueprints.rb +22 -28
  41. data/lib/branston/test/functional/iterations_controller_test.rb +149 -113
  42. data/lib/branston/test/functional/outcomes_controller_test.rb +94 -60
  43. data/lib/branston/test/functional/preconditions_controller_test.rb +101 -67
  44. data/lib/branston/test/functional/releases_controller_test.rb +85 -49
  45. data/lib/branston/test/functional/scenarios_controller_test.rb +104 -70
  46. data/lib/branston/test/functional/stories_controller_test.rb +41 -12
  47. data/lib/branston/test/functional/users_controller_test.rb +364 -43
  48. data/lib/branston/test/unit/iteration_test.rb +37 -6
  49. data/lib/branston/test/unit/outcome_test.rb +2 -2
  50. data/lib/branston/test/unit/participation_test.rb +2 -2
  51. data/lib/branston/test/unit/precondition_test.rb +3 -3
  52. data/lib/branston/test/unit/release_test.rb +4 -0
  53. data/lib/branston/test/unit/scenario_test.rb +4 -4
  54. data/lib/branston/test/unit/story_test.rb +62 -40
  55. data/lib/branston/test/unit/user_test.rb +195 -5
  56. metadata +136 -156
  57. data/lib/branston/app/controllers/user_roles_controller.rb +0 -105
  58. data/lib/branston/app/helpers/user_roles_helper.rb +0 -2
  59. data/lib/branston/app/models/user_role.rb +0 -21
  60. data/lib/branston/app/views/layouts/outcomes.html.erb +0 -17
  61. data/lib/branston/app/views/layouts/preconditions.html.erb +0 -17
  62. data/lib/branston/app/views/layouts/releases.html.erb +0 -17
  63. data/lib/branston/app/views/user_roles/edit.html.erb +0 -16
  64. data/lib/branston/app/views/user_roles/index.html.erb +0 -20
  65. data/lib/branston/app/views/user_roles/new.html.erb +0 -15
  66. data/lib/branston/app/views/user_roles/show.html.erb +0 -8
  67. data/lib/branston/coverage/app-controllers-application_controller_rb.html +0 -231
  68. data/lib/branston/coverage/app-controllers-iterations_controller_rb.html +0 -801
  69. data/lib/branston/coverage/app-controllers-outcomes_controller_rb.html +0 -759
  70. data/lib/branston/coverage/app-controllers-preconditions_controller_rb.html +0 -783
  71. data/lib/branston/coverage/app-controllers-releases_controller_rb.html +0 -705
  72. data/lib/branston/coverage/app-controllers-scenarios_controller_rb.html +0 -777
  73. data/lib/branston/coverage/app-controllers-sessions_controller_rb.html +0 -411
  74. data/lib/branston/coverage/app-controllers-stories_controller_rb.html +0 -1071
  75. data/lib/branston/coverage/app-controllers-user_roles_controller_rb.html +0 -693
  76. data/lib/branston/coverage/app-controllers-users_controller_rb.html +0 -315
  77. data/lib/branston/coverage/app-helpers-application_helper_rb.html +0 -327
  78. data/lib/branston/coverage/app-helpers-iterations_helper_rb.html +0 -363
  79. data/lib/branston/coverage/app-helpers-outcomes_helper_rb.html +0 -75
  80. data/lib/branston/coverage/app-helpers-preconditions_helper_rb.html +0 -75
  81. data/lib/branston/coverage/app-helpers-releases_helper_rb.html +0 -75
  82. data/lib/branston/coverage/app-helpers-sessions_helper_rb.html +0 -75
  83. data/lib/branston/coverage/app-helpers-stories_helper_rb.html +0 -75
  84. data/lib/branston/coverage/app-helpers-user_roles_helper_rb.html +0 -75
  85. data/lib/branston/coverage/app-models-iteration_rb.html +0 -321
  86. data/lib/branston/coverage/app-models-outcome_rb.html +0 -243
  87. data/lib/branston/coverage/app-models-participation_rb.html +0 -189
  88. data/lib/branston/coverage/app-models-precondition_rb.html +0 -243
  89. data/lib/branston/coverage/app-models-release_rb.html +0 -195
  90. data/lib/branston/coverage/app-models-scenario_rb.html +0 -231
  91. data/lib/branston/coverage/app-models-story_rb.html +0 -621
  92. data/lib/branston/coverage/app-models-user_rb.html +0 -513
  93. data/lib/branston/coverage/app-models-user_role_rb.html +0 -189
  94. data/lib/branston/coverage/index.html +0 -570
  95. data/lib/branston/coverage/jquery-1.3.2.min.js +0 -19
  96. data/lib/branston/coverage/jquery.tablesorter.min.js +0 -15
  97. data/lib/branston/coverage/lib-client_rb.html +0 -537
  98. data/lib/branston/coverage/lib-faker_extras_rb.html +0 -207
  99. data/lib/branston/coverage/lib-story_generator_rb.html +0 -873
  100. data/lib/branston/coverage/print.css +0 -12
  101. data/lib/branston/coverage/rcov.js +0 -42
  102. data/lib/branston/coverage/screen.css +0 -270
  103. data/lib/branston/db/migrate/20091127131037_create_user_roles.rb +0 -13
  104. data/lib/branston/db/migrate/20091127172950_add_story_id_to_user_role.rb +0 -10
  105. data/lib/branston/test/functional/user_roles_controller_test.rb +0 -71
  106. data/lib/branston/test/unit/helpers/user_roles_helper_test.rb +0 -4
  107. data/lib/branston/test/unit/user_role_test.rb +0 -9
  108. data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_flat.txt +0 -8
  109. data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_graph.html +0 -6718
  110. data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_tree.txt +0 -9942
  111. data/lib/branston/vendor/plugins/state_machine/CHANGELOG.rdoc +0 -298
  112. data/lib/branston/vendor/plugins/state_machine/LICENSE +0 -20
  113. data/lib/branston/vendor/plugins/state_machine/README.rdoc +0 -466
  114. data/lib/branston/vendor/plugins/state_machine/Rakefile +0 -98
  115. data/lib/branston/vendor/plugins/state_machine/examples/AutoShop_state.png +0 -0
  116. data/lib/branston/vendor/plugins/state_machine/examples/Car_state.png +0 -0
  117. data/lib/branston/vendor/plugins/state_machine/examples/TrafficLight_state.png +0 -0
  118. data/lib/branston/vendor/plugins/state_machine/examples/Vehicle_state.png +0 -0
  119. data/lib/branston/vendor/plugins/state_machine/examples/auto_shop.rb +0 -11
  120. data/lib/branston/vendor/plugins/state_machine/examples/car.rb +0 -19
  121. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/controller.rb +0 -51
  122. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/model.rb +0 -28
  123. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_edit.html.erb +0 -24
  124. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_index.html.erb +0 -23
  125. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_new.html.erb +0 -13
  126. data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_show.html.erb +0 -17
  127. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/controller.rb +0 -43
  128. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/migration.rb +0 -11
  129. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/model.rb +0 -23
  130. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_edit.html.erb +0 -25
  131. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_index.html.erb +0 -23
  132. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_new.html.erb +0 -14
  133. data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_show.html.erb +0 -17
  134. data/lib/branston/vendor/plugins/state_machine/examples/traffic_light.rb +0 -7
  135. data/lib/branston/vendor/plugins/state_machine/examples/vehicle.rb +0 -31
  136. data/lib/branston/vendor/plugins/state_machine/init.rb +0 -1
  137. data/lib/branston/vendor/plugins/state_machine/lib/state_machine.rb +0 -388
  138. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/assertions.rb +0 -36
  139. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/callback.rb +0 -189
  140. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/condition_proxy.rb +0 -94
  141. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/eval_helpers.rb +0 -67
  142. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/event.rb +0 -252
  143. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/event_collection.rb +0 -122
  144. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/extensions.rb +0 -149
  145. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/guard.rb +0 -230
  146. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations.rb +0 -68
  147. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record.rb +0 -492
  148. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record/locale.rb +0 -11
  149. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record/observer.rb +0 -41
  150. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/data_mapper.rb +0 -351
  151. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/data_mapper/observer.rb +0 -139
  152. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/sequel.rb +0 -322
  153. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/machine.rb +0 -1467
  154. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/machine_collection.rb +0 -155
  155. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/matcher.rb +0 -123
  156. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/matcher_helpers.rb +0 -54
  157. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/node_collection.rb +0 -152
  158. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/state.rb +0 -249
  159. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/state_collection.rb +0 -112
  160. data/lib/branston/vendor/plugins/state_machine/lib/state_machine/transition.rb +0 -394
  161. data/lib/branston/vendor/plugins/state_machine/state_machine.gemspec +0 -30
  162. data/lib/branston/vendor/plugins/state_machine/tasks/state_machine.rake +0 -1
  163. data/lib/branston/vendor/plugins/state_machine/tasks/state_machine.rb +0 -30
  164. data/lib/branston/vendor/plugins/state_machine/test/classes/switch.rb +0 -11
  165. data/lib/branston/vendor/plugins/state_machine/test/functional/state_machine_test.rb +0 -941
  166. data/lib/branston/vendor/plugins/state_machine/test/test_helper.rb +0 -4
  167. data/lib/branston/vendor/plugins/state_machine/test/unit/assertions_test.rb +0 -40
  168. data/lib/branston/vendor/plugins/state_machine/test/unit/callback_test.rb +0 -455
  169. data/lib/branston/vendor/plugins/state_machine/test/unit/condition_proxy_test.rb +0 -328
  170. data/lib/branston/vendor/plugins/state_machine/test/unit/eval_helpers_test.rb +0 -120
  171. data/lib/branston/vendor/plugins/state_machine/test/unit/event_collection_test.rb +0 -326
  172. data/lib/branston/vendor/plugins/state_machine/test/unit/event_test.rb +0 -743
  173. data/lib/branston/vendor/plugins/state_machine/test/unit/guard_test.rb +0 -908
  174. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/active_record_test.rb +0 -1367
  175. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/data_mapper_test.rb +0 -962
  176. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/sequel_test.rb +0 -859
  177. data/lib/branston/vendor/plugins/state_machine/test/unit/integrations_test.rb +0 -42
  178. data/lib/branston/vendor/plugins/state_machine/test/unit/invalid_event_test.rb +0 -7
  179. data/lib/branston/vendor/plugins/state_machine/test/unit/invalid_transition_test.rb +0 -7
  180. data/lib/branston/vendor/plugins/state_machine/test/unit/machine_collection_test.rb +0 -938
  181. data/lib/branston/vendor/plugins/state_machine/test/unit/machine_test.rb +0 -2004
  182. data/lib/branston/vendor/plugins/state_machine/test/unit/matcher_helpers_test.rb +0 -37
  183. data/lib/branston/vendor/plugins/state_machine/test/unit/matcher_test.rb +0 -155
  184. data/lib/branston/vendor/plugins/state_machine/test/unit/node_collection_test.rb +0 -207
  185. data/lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb +0 -280
  186. data/lib/branston/vendor/plugins/state_machine/test/unit/state_machine_test.rb +0 -31
  187. data/lib/branston/vendor/plugins/state_machine/test/unit/state_test.rb +0 -795
  188. data/lib/branston/vendor/plugins/state_machine/test/unit/transition_test.rb +0 -1212
data/README.rdoc CHANGED
@@ -18,7 +18,7 @@ There's a bit of a dependency chain needed to get things running. Cucumber has
18
18
  a dependency on Nokogiri, which itself has some libxml related dependencies
19
19
  including a dependency on a C compiler. On a clean Debian/Ubuntu box, this...
20
20
 
21
- sudo apt-get install libxml-ruby libxml2-dev libxslt-ruby libxslt-dev build-essential sqlite3
21
+ sudo apt-get install libxml-ruby libxml2-dev libxslt-ruby libxslt-dev build-essential sqlite3 libsqlite3-ruby libsqlite3-dev
22
22
  sudo gem install branston
23
23
 
24
24
  ...currently does the trick.
@@ -0,0 +1,25 @@
1
+ source :gemcutter
2
+ gem 'rails', '~> 2.3.5'
3
+ gem 'sqlite3-ruby', :require => 'sqlite3'
4
+
5
+ # bundler requires these gems in all environments
6
+ gem 'calendar_date_select', '>= 1.15'
7
+ gem 'aasm'
8
+ gem 'googlecharts', ' ~> 1.4.0'
9
+
10
+ group :development do
11
+ # bundler requires these gems in development
12
+ # currently nothing...
13
+ end
14
+
15
+ group :test do
16
+ gem 'cucumber', '0.4.4'
17
+ gem 'shoulda'
18
+ gem 'machinist'
19
+ gem 'webrat', '~> 0.5.3'
20
+ gem 'faker'
21
+ gem 'relevance-rcov'
22
+ gem 'ruby-prof'
23
+ gem 'ruby-debug'
24
+ end
25
+
@@ -0,0 +1,76 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ aasm (2.1.5)
5
+ actionmailer (2.3.11)
6
+ actionpack (= 2.3.11)
7
+ actionpack (2.3.11)
8
+ activesupport (= 2.3.11)
9
+ rack (~> 1.1.0)
10
+ activerecord (2.3.11)
11
+ activesupport (= 2.3.11)
12
+ activeresource (2.3.11)
13
+ activesupport (= 2.3.11)
14
+ activesupport (2.3.11)
15
+ builder (2.1.2)
16
+ calendar_date_select (1.16.1)
17
+ columnize (0.3.2)
18
+ cucumber (0.4.4)
19
+ builder (= 2.1.2)
20
+ diff-lcs (= 1.1.2)
21
+ polyglot (= 0.2.9)
22
+ term-ansicolor (= 1.0.4)
23
+ treetop (= 1.4.2)
24
+ diff-lcs (1.1.2)
25
+ faker (0.9.5)
26
+ i18n (~> 0.4)
27
+ googlecharts (1.4.0)
28
+ i18n (0.5.0)
29
+ linecache (0.43)
30
+ machinist (1.0.6)
31
+ nokogiri (1.4.4)
32
+ polyglot (0.2.9)
33
+ rack (1.1.0)
34
+ rails (2.3.11)
35
+ actionmailer (= 2.3.11)
36
+ actionpack (= 2.3.11)
37
+ activerecord (= 2.3.11)
38
+ activeresource (= 2.3.11)
39
+ activesupport (= 2.3.11)
40
+ rake (>= 0.8.3)
41
+ rake (0.8.7)
42
+ relevance-rcov (0.9.2.1)
43
+ ruby-debug (0.10.4)
44
+ columnize (>= 0.1)
45
+ ruby-debug-base (~> 0.10.4.0)
46
+ ruby-debug-base (0.10.4)
47
+ linecache (>= 0.3)
48
+ ruby-prof (0.9.1)
49
+ shoulda (2.11.3)
50
+ sqlite3 (1.3.3)
51
+ sqlite3-ruby (1.3.3)
52
+ sqlite3 (>= 1.3.3)
53
+ term-ansicolor (1.0.4)
54
+ treetop (1.4.2)
55
+ polyglot (>= 0.2.5)
56
+ webrat (0.5.3)
57
+ nokogiri (>= 1.2.0)
58
+ rack (>= 1.0)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ aasm
65
+ calendar_date_select (>= 1.15)
66
+ cucumber (= 0.4.4)
67
+ faker
68
+ googlecharts (~> 1.4.0)
69
+ machinist
70
+ rails (~> 2.3.5)
71
+ relevance-rcov
72
+ ruby-debug
73
+ ruby-prof
74
+ shoulda
75
+ sqlite3-ruby
76
+ webrat (~> 0.5.3)
@@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
20
20
  protect_from_forgery # See ActionController::RequestForgeryProtection for details
21
21
 
22
22
  # Scrub sensitive parameters from your log
23
- # filter_parameter_logging :password
23
+ filter_parameter_logging :password
24
24
 
25
25
  # RESTful authentication system
26
26
  include AuthenticatedSystem
@@ -109,6 +109,8 @@ class OutcomesController < ApplicationController
109
109
  end
110
110
  end
111
111
 
112
+ private
113
+
112
114
  def find_scenario
113
115
  @scenario = Scenario.find(params[:scenario_id])
114
116
  end
@@ -15,6 +15,7 @@
15
15
  class StoriesController < ApplicationController
16
16
 
17
17
  layout 'main'
18
+ before_filter :login_or_password_required, :only => [:show, :generate_feature]
18
19
  before_filter :login_required, :except => [:show, :generate_feature]
19
20
  before_filter :retrieve_iterations, :except => [:generate_feature]
20
21
  before_filter :load_iteration, :except => [:generate_feature, :show]
@@ -42,9 +43,9 @@ class StoriesController < ApplicationController
42
43
  Story.for_iteration(@iteration.id).map { |s|
43
44
  @total_assigned_points += s.points
44
45
  }
45
-
46
+
46
47
  @assignment_difference = @total_assigned_points - @iteration.velocity
47
-
48
+
48
49
  respond_to do |format|
49
50
  format.html # index.html.erb
50
51
  format.xml { render :xml => @stories }
@@ -56,119 +57,114 @@ class StoriesController < ApplicationController
56
57
  def show
57
58
  @story = Story.find_by_slug(params[:id])
58
59
  @iteration = @story.iteration unless @story.nil?
59
-
60
+
60
61
  respond_to do |format|
61
62
  if @story
62
63
  format.html
63
64
  format.xml {
64
- render :xml => (@story.to_xml :include => {
65
+ render :xml => (@story.to_xml :include => {
65
66
  :scenarios => { :include => [:preconditions, :outcomes] }
66
67
  })
67
68
  }
68
69
  format.js { @active = true }
69
- else
70
- format.html {
71
- render_optional_error_file 404
72
- }
73
- format.all { render :nothing => true, :status => 404 }
74
- end
70
+ else
71
+ format.html { render_optional_error_file 404 }
72
+ format.all { render :nothing => true, :status => 404 }
75
73
  end
76
74
  end
75
+ end
77
76
 
78
- # GET /stories/new
79
- # GET /stories/new.xml
80
- def new
81
- @story = Story.new(:iteration => @iteration)
77
+ # GET /stories/new
78
+ # GET /stories/new.xml
79
+ def new
80
+ @story = Story.new(:iteration => @iteration)
82
81
 
83
- respond_to do |format|
84
- format.html # new.html.erb
85
- format.xml { render :xml => @story }
86
- end
82
+ respond_to do |format|
83
+ format.html # new.html.erb
84
+ format.xml { render :xml => @story }
87
85
  end
86
+ end
88
87
 
89
- # GET /stories/1/edit
90
- def edit
91
- @story = Story.find_by_slug(params[:id])
92
- end
88
+ # GET /stories/1/edit
89
+ def edit
90
+ @story = Story.find_by_slug(params[:id])
91
+ end
92
+
93
+ # POST /stories
94
+ # POST /stories.xml
95
+ def create
96
+ @story = Story.new(params[:story])
97
+ @story.author = current_user
98
+ @story.iteration = @iteration
93
99
 
94
- # POST /stories
95
- # POST /stories.xml
96
- def create
97
- @story = Story.new(params[:story])
98
- @story.author = current_user
99
- @story.iteration = @iteration
100
-
101
- respond_to do |format|
102
- if @story.save
103
- flash[:notice] = 'Story was successfully created.'
104
- format.html { redirect_to iteration_stories_path(@iteration) }
105
- format.xml { render :xml => @story, :status => :created, :location => @story }
106
- else
107
- format.html { render :action => "new" }
108
- format.xml { render :xml => @story.errors, :status => :unprocessable_entity }
109
- end
100
+ respond_to do |format|
101
+ if @story.save
102
+ flash[:notice] = 'Story was successfully created.'
103
+ format.html { redirect_to iteration_stories_path(@iteration) }
104
+ format.xml { render :xml => @story, :status => :created, :location => @story }
105
+ else
106
+ format.html { render :action => "new" }
107
+ format.xml { render :xml => @story.errors, :status => :unprocessable_entity }
110
108
  end
111
109
  end
110
+ end
112
111
 
113
- # PUT /stories/"1
114
- # PUT /stories/1.xml
115
- def update
116
- @story = Story.find_by_slug(params[:id])
117
-
118
- if params[:story] and params[:story][:status]
119
- if params[:story][:status] == 'in_progress'
120
- @story.assign
121
- end
122
-
123
- if params[:story][:status] == 'quality_assurance'
124
- @story.check_quality
125
- end
126
-
127
- if params[:story][:status] == 'new'
128
- @story.back_to_new
129
- end
112
+ # PUT /stories/"1
113
+ # PUT /stories/1.xml
114
+ def update
115
+ @story = Story.find_by_slug(params[:id])
130
116
 
131
- if params[:story][:status] == 'completed'
132
- @story.finish
133
- end
134
- end
117
+ if params[:story] and params[:story][:status]
118
+ @story.assign if params[:story][:status] == 'in_progress'
119
+ @story.check_quality if params[:story][:status] == 'quality_assurance'
120
+ @story.back_to_new if params[:story][:status] == 'new'
121
+ @story.finish if params[:story][:status] == 'completed'
122
+ end
135
123
 
136
- respond_to do |format|
137
- if @story.update_attributes(params[:story])
138
- flash[:notice] = 'Story was successfully updated.'
139
- format.html { redirect_to iteration_story_path(@iteration, @story) }
140
- format.xml { head :ok }
141
- format.js { redirect_to iteration_stories_path(@iteration) }
142
- else
143
- format.html { render :action => "edit" }
144
- format.xml { render :xml => @story.errors, :status => :unprocessable_entity }
145
- end
124
+ respond_to do |format|
125
+ if @story.update_attributes(params[:story])
126
+ flash[:notice] = 'Story was successfully updated.'
127
+ format.html { redirect_to iteration_story_path(@iteration, @story) }
128
+ format.xml { head :ok }
129
+ format.js { redirect_to iteration_stories_path(@iteration) }
130
+ else
131
+ format.html { render :action => "edit" }
132
+ format.xml { render :xml => @story.errors, :status => :unprocessable_entity }
146
133
  end
147
-
148
-
149
134
  end
135
+ end
150
136
 
151
- # DELETE /stories/1
152
- # DELETE /stories/1.xml
153
- def destroy
154
- @story = Story.find_by_slug(params[:id])
155
- @story.destroy
137
+ # DELETE /stories/1
138
+ # DELETE /stories/1.xml
139
+ def destroy
140
+ @story = Story.find_by_slug(params[:id])
141
+ @story.destroy
156
142
 
157
- respond_to do |format|
158
- format.html { redirect_to iteration_stories_path(@iteration) }
159
- format.xml { head :ok }
160
- end
143
+ respond_to do |format|
144
+ format.html { redirect_to iteration_stories_path(@iteration) }
145
+ format.xml { head :ok }
161
146
  end
147
+ end
162
148
 
163
149
 
164
- private
150
+ private
165
151
 
166
- def retrieve_iterations
167
- @iterations = Iteration.all
168
- end
152
+ def retrieve_iterations
153
+ @iterations = Iteration.all
154
+ end
155
+
156
+ def load_iteration
157
+ @iteration = Iteration.find(params[:iteration_id])
158
+ end
169
159
 
170
- def load_iteration
171
- @iteration = Iteration.find(params[:iteration_id])
160
+ def login_or_password_required
161
+ user = User.authenticate(params[:login], params[:password])
162
+ if user
163
+ return true
164
+ else
165
+ return false
172
166
  end
173
167
  end
174
168
 
169
+ end
170
+
@@ -16,27 +16,85 @@ class UsersController < ApplicationController
16
16
 
17
17
  layout 'main'
18
18
 
19
- # render new.rhtml
19
+ before_filter :login_required
20
+ before_filter :find_user, :only => [:suspend, :destroy, :activate]
21
+ before_filter :must_be_admin, :only => [:new, :create, :destroy, :suspend, :activate]
22
+ before_filter :must_be_admin_or_self, :only => [:edit, :update]
23
+
24
+ def index
25
+ @users = User.find(:all)
26
+ end
27
+
20
28
  def new
21
29
  @user = User.new
22
30
  end
23
31
 
24
32
  def create
25
- logout_keeping_session!
26
33
  @user = User.new(params[:user])
27
- success = @user && @user.save
28
- if success && @user.errors.empty?
29
- # Protects against session fixation attacks, causes request forgery
30
- # protection if visitor resubmits an earlier form using back
31
- # button. Uncomment if you understand the tradeoffs.
32
- # reset session
33
- self.current_user = @user # !! now logged in
34
- redirect_back_or_default('/')
35
- flash[:notice] = "Thanks for signing up! We're sending you an email with your activation code."
34
+ @user.role = params[:user][:role] if current_user.has_role?("admin")
35
+ if @user && @user.valid? && @user.save!
36
+ redirect_to users_url
37
+ flash[:notice] = "User created."
36
38
  else
37
39
  flash[:error] = "We couldn't set up that account, sorry. Please try again, or contact an admin (link is above)."
38
40
  render :action => 'new'
39
41
  end
40
42
  end
43
+
44
+ def edit
45
+ @user = User.find(params[:id])
46
+ end
47
+
48
+ def update
49
+ @user = User.find(params[:id])
50
+ @user.role = params[:user][:role] if current_user.has_role?("admin")
51
+ if @user.update_attributes(params[:user])
52
+ redirect_to users_path
53
+ else
54
+ render :action => 'edit'
55
+ end
56
+ end
57
+
58
+ def suspend
59
+ @user.suspend!
60
+ redirect_to users_path
61
+ end
62
+
63
+ def activate
64
+ @user.activate!
65
+ redirect_to users_path
66
+ end
67
+
68
+ def destroy
69
+ @user.delete!
70
+ redirect_to users_path
71
+ end
72
+
73
+ protected
74
+
75
+ def find_user
76
+ @user = User.find(params[:id])
77
+ end
78
+
79
+ # A security filter which freezes out all non-admin users except the user
80
+ # who is the user identified by params[:id]
81
+ #
82
+ def must_be_admin_or_self
83
+ user = User.find(params[:id])
84
+ unless current_user.has_role?("admin") || current_user == user
85
+ flash[:error] = "You are not allowed to do that."
86
+ redirect_to users_path
87
+ end
88
+ end
89
+
90
+ # A security filter which freezes out all non-admin users.
91
+ #
92
+ def must_be_admin
93
+ unless current_user.has_role?("admin")
94
+ flash[:error] = "You are not allowed to do that."
95
+ redirect_to users_path
96
+ end
97
+ end
98
+
41
99
  end
42
100