branston 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/branston/Gemfile +25 -0
- data/lib/branston/Gemfile.lock +76 -0
- data/lib/branston/app/controllers/application_controller.rb +1 -1
- data/lib/branston/app/controllers/outcomes_controller.rb +2 -0
- data/lib/branston/app/controllers/stories_controller.rb +82 -86
- data/lib/branston/app/controllers/users_controller.rb +69 -11
- data/lib/branston/app/helpers/iterations_helper.rb +13 -13
- data/lib/branston/app/models/iteration.rb +3 -1
- data/lib/branston/app/models/release.rb +0 -1
- data/lib/branston/app/models/story.rb +30 -28
- data/lib/branston/app/models/user.rb +46 -1
- data/lib/branston/app/views/layouts/_header.html.erb +8 -3
- data/lib/branston/app/views/layouts/user_roles.html.erb +5 -5
- data/lib/branston/app/views/sessions/new.html.erb +8 -14
- data/lib/branston/app/views/users/_admin_controls.html.erb +14 -0
- data/lib/branston/app/views/users/_form.html.erb +27 -0
- data/lib/branston/app/views/users/edit.html.erb +9 -0
- data/lib/branston/app/views/users/index.html.erb +14 -0
- data/lib/branston/app/views/users/new.html.erb +3 -22
- data/lib/branston/config/boot.rb +20 -0
- data/lib/branston/config/environment.rb +2 -7
- data/lib/branston/config/environments/test.rb +0 -8
- data/lib/branston/config/preinitializer.rb +21 -0
- data/lib/branston/config/routes.rb +15 -10
- data/lib/branston/db/development.sqlite3 +0 -0
- data/lib/branston/db/development_structure.sql +21 -8
- data/lib/branston/db/migrate/20100723161424_add_state_to_user.rb +12 -0
- data/lib/branston/db/migrate/20100726150322_add_activation_fields_to_user.rb +12 -0
- data/lib/branston/db/migrate/20100729125551_set_default_user_state_to_pending.rb +10 -0
- data/lib/branston/db/migrate/20100812133837_add_is_admin_property_to_user.rb +10 -0
- data/lib/branston/db/migrate/20100812140532_set_default_user_state_to_active.rb +10 -0
- data/lib/branston/db/migrate/20100812143455_add_default_admin_user.rb +17 -0
- data/lib/branston/db/migrate/20110408162438_remove_is_admin_property_and_add_role_instead.rb +12 -0
- data/lib/branston/db/pristine.sqlite3 +0 -0
- data/lib/branston/db/schema.rb +6 -8
- data/lib/branston/db/test.sqlite3 +0 -0
- data/lib/branston/log/development.log +1181 -433
- data/lib/branston/log/test.log +145306 -52026
- data/lib/branston/test/blueprints.rb +22 -28
- data/lib/branston/test/functional/iterations_controller_test.rb +149 -113
- data/lib/branston/test/functional/outcomes_controller_test.rb +94 -60
- data/lib/branston/test/functional/preconditions_controller_test.rb +101 -67
- data/lib/branston/test/functional/releases_controller_test.rb +85 -49
- data/lib/branston/test/functional/scenarios_controller_test.rb +104 -70
- data/lib/branston/test/functional/stories_controller_test.rb +41 -12
- data/lib/branston/test/functional/users_controller_test.rb +364 -43
- data/lib/branston/test/unit/iteration_test.rb +37 -6
- data/lib/branston/test/unit/outcome_test.rb +2 -2
- data/lib/branston/test/unit/participation_test.rb +2 -2
- data/lib/branston/test/unit/precondition_test.rb +3 -3
- data/lib/branston/test/unit/release_test.rb +4 -0
- data/lib/branston/test/unit/scenario_test.rb +4 -4
- data/lib/branston/test/unit/story_test.rb +62 -40
- data/lib/branston/test/unit/user_test.rb +195 -5
- metadata +136 -156
- data/lib/branston/app/controllers/user_roles_controller.rb +0 -105
- data/lib/branston/app/helpers/user_roles_helper.rb +0 -2
- data/lib/branston/app/models/user_role.rb +0 -21
- data/lib/branston/app/views/layouts/outcomes.html.erb +0 -17
- data/lib/branston/app/views/layouts/preconditions.html.erb +0 -17
- data/lib/branston/app/views/layouts/releases.html.erb +0 -17
- data/lib/branston/app/views/user_roles/edit.html.erb +0 -16
- data/lib/branston/app/views/user_roles/index.html.erb +0 -20
- data/lib/branston/app/views/user_roles/new.html.erb +0 -15
- data/lib/branston/app/views/user_roles/show.html.erb +0 -8
- data/lib/branston/coverage/app-controllers-application_controller_rb.html +0 -231
- data/lib/branston/coverage/app-controllers-iterations_controller_rb.html +0 -801
- data/lib/branston/coverage/app-controllers-outcomes_controller_rb.html +0 -759
- data/lib/branston/coverage/app-controllers-preconditions_controller_rb.html +0 -783
- data/lib/branston/coverage/app-controllers-releases_controller_rb.html +0 -705
- data/lib/branston/coverage/app-controllers-scenarios_controller_rb.html +0 -777
- data/lib/branston/coverage/app-controllers-sessions_controller_rb.html +0 -411
- data/lib/branston/coverage/app-controllers-stories_controller_rb.html +0 -1071
- data/lib/branston/coverage/app-controllers-user_roles_controller_rb.html +0 -693
- data/lib/branston/coverage/app-controllers-users_controller_rb.html +0 -315
- data/lib/branston/coverage/app-helpers-application_helper_rb.html +0 -327
- data/lib/branston/coverage/app-helpers-iterations_helper_rb.html +0 -363
- data/lib/branston/coverage/app-helpers-outcomes_helper_rb.html +0 -75
- data/lib/branston/coverage/app-helpers-preconditions_helper_rb.html +0 -75
- data/lib/branston/coverage/app-helpers-releases_helper_rb.html +0 -75
- data/lib/branston/coverage/app-helpers-sessions_helper_rb.html +0 -75
- data/lib/branston/coverage/app-helpers-stories_helper_rb.html +0 -75
- data/lib/branston/coverage/app-helpers-user_roles_helper_rb.html +0 -75
- data/lib/branston/coverage/app-models-iteration_rb.html +0 -321
- data/lib/branston/coverage/app-models-outcome_rb.html +0 -243
- data/lib/branston/coverage/app-models-participation_rb.html +0 -189
- data/lib/branston/coverage/app-models-precondition_rb.html +0 -243
- data/lib/branston/coverage/app-models-release_rb.html +0 -195
- data/lib/branston/coverage/app-models-scenario_rb.html +0 -231
- data/lib/branston/coverage/app-models-story_rb.html +0 -621
- data/lib/branston/coverage/app-models-user_rb.html +0 -513
- data/lib/branston/coverage/app-models-user_role_rb.html +0 -189
- data/lib/branston/coverage/index.html +0 -570
- data/lib/branston/coverage/jquery-1.3.2.min.js +0 -19
- data/lib/branston/coverage/jquery.tablesorter.min.js +0 -15
- data/lib/branston/coverage/lib-client_rb.html +0 -537
- data/lib/branston/coverage/lib-faker_extras_rb.html +0 -207
- data/lib/branston/coverage/lib-story_generator_rb.html +0 -873
- data/lib/branston/coverage/print.css +0 -12
- data/lib/branston/coverage/rcov.js +0 -42
- data/lib/branston/coverage/screen.css +0 -270
- data/lib/branston/db/migrate/20091127131037_create_user_roles.rb +0 -13
- data/lib/branston/db/migrate/20091127172950_add_story_id_to_user_role.rb +0 -10
- data/lib/branston/test/functional/user_roles_controller_test.rb +0 -71
- data/lib/branston/test/unit/helpers/user_roles_helper_test.rb +0 -4
- data/lib/branston/test/unit/user_role_test.rb +0 -9
- data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_flat.txt +0 -8
- data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_graph.html +0 -6718
- data/lib/branston/tmp/performance/BrowsingTest#test_homepage_process_time_tree.txt +0 -9942
- data/lib/branston/vendor/plugins/state_machine/CHANGELOG.rdoc +0 -298
- data/lib/branston/vendor/plugins/state_machine/LICENSE +0 -20
- data/lib/branston/vendor/plugins/state_machine/README.rdoc +0 -466
- data/lib/branston/vendor/plugins/state_machine/Rakefile +0 -98
- data/lib/branston/vendor/plugins/state_machine/examples/AutoShop_state.png +0 -0
- data/lib/branston/vendor/plugins/state_machine/examples/Car_state.png +0 -0
- data/lib/branston/vendor/plugins/state_machine/examples/TrafficLight_state.png +0 -0
- data/lib/branston/vendor/plugins/state_machine/examples/Vehicle_state.png +0 -0
- data/lib/branston/vendor/plugins/state_machine/examples/auto_shop.rb +0 -11
- data/lib/branston/vendor/plugins/state_machine/examples/car.rb +0 -19
- data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/controller.rb +0 -51
- data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/model.rb +0 -28
- data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_edit.html.erb +0 -24
- data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_index.html.erb +0 -23
- data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_new.html.erb +0 -13
- data/lib/branston/vendor/plugins/state_machine/examples/merb-rest/view_show.html.erb +0 -17
- data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/controller.rb +0 -43
- data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/migration.rb +0 -11
- data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/model.rb +0 -23
- data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_edit.html.erb +0 -25
- data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_index.html.erb +0 -23
- data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_new.html.erb +0 -14
- data/lib/branston/vendor/plugins/state_machine/examples/rails-rest/view_show.html.erb +0 -17
- data/lib/branston/vendor/plugins/state_machine/examples/traffic_light.rb +0 -7
- data/lib/branston/vendor/plugins/state_machine/examples/vehicle.rb +0 -31
- data/lib/branston/vendor/plugins/state_machine/init.rb +0 -1
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine.rb +0 -388
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/assertions.rb +0 -36
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/callback.rb +0 -189
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/condition_proxy.rb +0 -94
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/eval_helpers.rb +0 -67
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/event.rb +0 -252
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/event_collection.rb +0 -122
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/extensions.rb +0 -149
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/guard.rb +0 -230
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations.rb +0 -68
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record.rb +0 -492
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record/locale.rb +0 -11
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/active_record/observer.rb +0 -41
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/data_mapper.rb +0 -351
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/data_mapper/observer.rb +0 -139
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/integrations/sequel.rb +0 -322
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/machine.rb +0 -1467
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/machine_collection.rb +0 -155
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/matcher.rb +0 -123
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/matcher_helpers.rb +0 -54
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/node_collection.rb +0 -152
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/state.rb +0 -249
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/state_collection.rb +0 -112
- data/lib/branston/vendor/plugins/state_machine/lib/state_machine/transition.rb +0 -394
- data/lib/branston/vendor/plugins/state_machine/state_machine.gemspec +0 -30
- data/lib/branston/vendor/plugins/state_machine/tasks/state_machine.rake +0 -1
- data/lib/branston/vendor/plugins/state_machine/tasks/state_machine.rb +0 -30
- data/lib/branston/vendor/plugins/state_machine/test/classes/switch.rb +0 -11
- data/lib/branston/vendor/plugins/state_machine/test/functional/state_machine_test.rb +0 -941
- data/lib/branston/vendor/plugins/state_machine/test/test_helper.rb +0 -4
- data/lib/branston/vendor/plugins/state_machine/test/unit/assertions_test.rb +0 -40
- data/lib/branston/vendor/plugins/state_machine/test/unit/callback_test.rb +0 -455
- data/lib/branston/vendor/plugins/state_machine/test/unit/condition_proxy_test.rb +0 -328
- data/lib/branston/vendor/plugins/state_machine/test/unit/eval_helpers_test.rb +0 -120
- data/lib/branston/vendor/plugins/state_machine/test/unit/event_collection_test.rb +0 -326
- data/lib/branston/vendor/plugins/state_machine/test/unit/event_test.rb +0 -743
- data/lib/branston/vendor/plugins/state_machine/test/unit/guard_test.rb +0 -908
- data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/active_record_test.rb +0 -1367
- data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/data_mapper_test.rb +0 -962
- data/lib/branston/vendor/plugins/state_machine/test/unit/integrations/sequel_test.rb +0 -859
- data/lib/branston/vendor/plugins/state_machine/test/unit/integrations_test.rb +0 -42
- data/lib/branston/vendor/plugins/state_machine/test/unit/invalid_event_test.rb +0 -7
- data/lib/branston/vendor/plugins/state_machine/test/unit/invalid_transition_test.rb +0 -7
- data/lib/branston/vendor/plugins/state_machine/test/unit/machine_collection_test.rb +0 -938
- data/lib/branston/vendor/plugins/state_machine/test/unit/machine_test.rb +0 -2004
- data/lib/branston/vendor/plugins/state_machine/test/unit/matcher_helpers_test.rb +0 -37
- data/lib/branston/vendor/plugins/state_machine/test/unit/matcher_test.rb +0 -155
- data/lib/branston/vendor/plugins/state_machine/test/unit/node_collection_test.rb +0 -207
- data/lib/branston/vendor/plugins/state_machine/test/unit/state_collection_test.rb +0 -280
- data/lib/branston/vendor/plugins/state_machine/test/unit/state_machine_test.rb +0 -31
- data/lib/branston/vendor/plugins/state_machine/test/unit/state_test.rb +0 -795
- data/lib/branston/vendor/plugins/state_machine/test/unit/transition_test.rb +0 -1212
@@ -2,12 +2,43 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class IterationTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
-
|
5
|
+
should validate_presence_of :name
|
6
|
+
should validate_presence_of :velocity
|
7
|
+
should validate_numericality_of :velocity
|
8
|
+
|
9
|
+
should have_many :stories
|
10
|
+
should have_many(:geeks).through(:participations)
|
11
|
+
should have_many :participations
|
12
|
+
should belong_to :release
|
13
|
+
|
14
|
+
context "An Iterations's burndown data method" do
|
15
|
+
|
16
|
+
context "for incomplete stories" do
|
17
|
+
|
18
|
+
setup do
|
19
|
+
@iteration = Iteration.make
|
20
|
+
Story.make(:points => 5, :iteration => @iteration)
|
21
|
+
Story.make(:points => 2, :iteration => @iteration)
|
22
|
+
end
|
23
|
+
|
24
|
+
should "return an empty array" do
|
25
|
+
assert_equal @iteration.burndown_data, []
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "for completed and qa stories" do
|
30
|
+
setup do
|
31
|
+
@iteration = Iteration.make
|
32
|
+
Story.make(:points => 5, :iteration => @iteration, :status => "quality_assurance")
|
33
|
+
Story.make(:points => 5, :iteration => @iteration, :status => "completed")
|
34
|
+
Story.make(:points => 2, :iteration => @iteration, :status => "completed")
|
35
|
+
end
|
36
|
+
|
37
|
+
should "return a points value" do
|
38
|
+
assert_match /7/, @iteration.burndown_data.to_s
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
6
42
|
|
7
|
-
should_have_many :stories
|
8
|
-
should_have_many :geeks, :through => :participations
|
9
|
-
should_have_many :participations
|
10
|
-
should_belong_to :release
|
11
|
-
|
12
43
|
end
|
13
44
|
|
@@ -2,11 +2,11 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class ScenarioTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
-
|
5
|
+
should validate_presence_of :title
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
should belong_to :story
|
8
|
+
should have_many :preconditions
|
9
|
+
should have_many :outcomes
|
10
10
|
|
11
11
|
end
|
12
12
|
|
@@ -2,63 +2,85 @@ require 'test_helper'
|
|
2
2
|
include StoryGenerator
|
3
3
|
|
4
4
|
class StoryTest < ActiveSupport::TestCase
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
|
6
|
+
should validate_presence_of :description
|
7
|
+
should validate_presence_of :points
|
8
|
+
should have_many :scenarios
|
9
|
+
should belong_to :iteration
|
10
|
+
should belong_to :author
|
11
|
+
|
12
12
|
context "a Story" do
|
13
13
|
setup do
|
14
|
-
@story = Factory.make_story(:title => "Product Search",
|
14
|
+
@story = Factory.make_story(:title => "Product Search",
|
15
15
|
:description => "I should be able to search for products by title")
|
16
16
|
@feature_file = FEATURE_PATH + @story.feature_filename
|
17
17
|
@step_file = FEATURE_PATH + @story.step_filename
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
teardown do
|
21
21
|
FileUtils.rm @feature_file if @feature_file != nil and File.exists? @feature_file
|
22
22
|
FileUtils.rm @step_file if @step_file != nil and File.exists? @step_file
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
should "start life with status new" do
|
26
26
|
assert @story.new?
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
|
+
context "attempting to transition from :new to :finish" do
|
30
|
+
should "raise AASM::InvalidTransition" do
|
31
|
+
assert_raise AASM::InvalidTransition do
|
32
|
+
@story.finish
|
33
|
+
end
|
34
|
+
end
|
35
|
+
should "leave the story in a :new state" do
|
36
|
+
assert @story.new?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "attempting to transition from :new to :check_quality" do
|
41
|
+
should "raise AASM::InvalidTransition" do
|
42
|
+
assert_raise AASM::InvalidTransition do
|
43
|
+
@story.check_quality
|
44
|
+
end
|
45
|
+
end
|
46
|
+
should "leave the story in a :new state" do
|
47
|
+
assert @story.new?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
29
51
|
context "transisted to in_progress" do
|
30
52
|
setup do
|
31
53
|
assert @story.assign
|
32
54
|
end
|
33
|
-
|
55
|
+
|
34
56
|
should "transist to in_progress" do
|
35
57
|
assert @story.in_progress?
|
36
58
|
end
|
37
|
-
|
59
|
+
|
38
60
|
context "then transisted to completed" do
|
39
61
|
setup do
|
40
62
|
assert @story.finish
|
41
63
|
end
|
42
|
-
|
64
|
+
|
43
65
|
should "transist to completed" do
|
44
66
|
assert @story.completed?
|
45
67
|
end
|
46
|
-
|
68
|
+
|
47
69
|
should "set the completed date when in the completed state" do
|
48
70
|
assert_equal Date.today, @story.completed_date
|
49
71
|
end
|
50
72
|
end
|
51
73
|
end
|
52
|
-
|
74
|
+
|
53
75
|
should "set a slug when its saved" do
|
54
76
|
assert_not_nil @story.slug
|
55
77
|
assert_equal 'product-search', @story.slug
|
56
|
-
|
78
|
+
|
57
79
|
@story.title = "updated title"
|
58
80
|
assert @story.save
|
59
81
|
assert_equal 'updated-title', @story.slug
|
60
82
|
end
|
61
|
-
|
83
|
+
|
62
84
|
should "have a unique title" do
|
63
85
|
assert_no_difference 'Story.count' do
|
64
86
|
assert_raise ActiveRecord::RecordInvalid do
|
@@ -67,15 +89,15 @@ class StoryTest < ActiveSupport::TestCase
|
|
67
89
|
end
|
68
90
|
end
|
69
91
|
end
|
70
|
-
|
92
|
+
|
71
93
|
should "know by convention what its filename ought to be" do
|
72
94
|
assert_equal "product_search.feature", @story.feature_filename
|
73
95
|
end
|
74
|
-
|
96
|
+
|
75
97
|
should "generate a feature file that can be run by cucumber" do
|
76
98
|
@story.generate(@story)
|
77
99
|
assert File.exists? @feature_file
|
78
|
-
|
100
|
+
|
79
101
|
f = File.open(@feature_file, "r")
|
80
102
|
begin
|
81
103
|
assert_equal "Feature: Product Search\n", f.gets
|
@@ -92,7 +114,7 @@ class StoryTest < ActiveSupport::TestCase
|
|
92
114
|
f.close
|
93
115
|
end
|
94
116
|
end
|
95
|
-
|
117
|
+
|
96
118
|
should "generate a skeleton step definition file" do
|
97
119
|
@story.generate(@story)
|
98
120
|
assert File.exists? @step_file
|
@@ -104,70 +126,70 @@ class StoryTest < ActiveSupport::TestCase
|
|
104
126
|
assert_equal "\tpending\n", f.gets
|
105
127
|
assert_equal "end\n", f.gets
|
106
128
|
assert_equal "\n", f.gets
|
107
|
-
|
129
|
+
|
108
130
|
pc = @story.scenarios.first.preconditions[1]
|
109
131
|
assert_equal "Given #{regexp(pc.to_s)} do |a, b|\n", f.gets
|
110
132
|
assert_equal "\t#TODO: Define these steps\n", f.gets
|
111
133
|
assert_equal "\tpending\n", f.gets
|
112
134
|
assert_equal "end\n", f.gets
|
113
135
|
assert_equal "\n", f.gets
|
114
|
-
|
136
|
+
|
115
137
|
outcome = @story.scenarios.first.outcomes[0]
|
116
138
|
assert_equal "Then #{regexp(outcome.to_s)} do |a|\n", f.gets
|
117
139
|
assert_equal "\t#TODO: Define these steps\n", f.gets
|
118
140
|
assert_equal "\tpending\n", f.gets
|
119
141
|
assert_equal "end\n", f.gets
|
120
142
|
assert_equal "\n", f.gets
|
121
|
-
|
143
|
+
|
122
144
|
outcome = @story.scenarios.first.outcomes[1]
|
123
145
|
assert_equal "Then #{regexp(outcome.to_s)} do |a|\n", f.gets
|
124
146
|
assert_equal "\t#TODO: Define these steps\n", f.gets
|
125
147
|
assert_equal "\tpending\n", f.gets
|
126
148
|
assert_equal "end\n", f.gets
|
127
149
|
assert_equal "\n", f.gets
|
128
|
-
|
150
|
+
|
129
151
|
pc = @story.scenarios.last.preconditions[0]
|
130
152
|
assert_equal "Given #{regexp(pc.to_s)} do |a|\n", f.gets
|
131
153
|
assert_equal "\t#TODO: Define these steps\n", f.gets
|
132
154
|
assert_equal "\tpending\n", f.gets
|
133
155
|
assert_equal "end\n", f.gets
|
134
156
|
assert_equal "\n", f.gets
|
135
|
-
|
157
|
+
|
136
158
|
pc = @story.scenarios.last.preconditions[1]
|
137
159
|
assert_equal "Given #{regexp(pc.to_s)} do |a, b|\n", f.gets
|
138
160
|
assert_equal "\t#TODO: Define these steps\n", f.gets
|
139
161
|
assert_equal "\tpending\n", f.gets
|
140
162
|
assert_equal "end\n", f.gets
|
141
163
|
assert_equal "\n", f.gets
|
142
|
-
|
164
|
+
|
143
165
|
outcome = @story.scenarios.last.outcomes[0]
|
144
166
|
assert_equal "Then #{regexp(outcome.to_s)} do |a|\n", f.gets
|
145
167
|
assert_equal "\t#TODO: Define these steps\n", f.gets
|
146
168
|
assert_equal "\tpending\n", f.gets
|
147
169
|
assert_equal "end\n", f.gets
|
148
170
|
assert_equal "\n", f.gets
|
149
|
-
|
171
|
+
|
150
172
|
outcome = @story.scenarios.last.outcomes[1]
|
151
173
|
assert_equal "Then #{regexp(outcome.to_s)} do |a|\n", f.gets
|
152
174
|
assert_equal "\t#TODO: Define these steps\n", f.gets
|
153
175
|
assert_equal "\tpending\n", f.gets
|
154
176
|
assert_equal "end\n", f.gets
|
155
177
|
assert_equal "\n", f.gets
|
156
|
-
|
178
|
+
|
157
179
|
assert_equal "\n", f.gets
|
158
180
|
ensure
|
159
181
|
f.close
|
160
182
|
end
|
161
183
|
end
|
162
|
-
|
184
|
+
|
163
185
|
end
|
164
|
-
|
186
|
+
|
165
187
|
context "The Story class" do
|
166
|
-
|
188
|
+
|
167
189
|
should "have an in_progress named_scope" do
|
168
190
|
assert Story.respond_to?("in_progress")
|
169
191
|
end
|
170
|
-
|
192
|
+
|
171
193
|
context "named_scope in_progress" do
|
172
194
|
setup do
|
173
195
|
@story = Story.make
|
@@ -175,25 +197,25 @@ class StoryTest < ActiveSupport::TestCase
|
|
175
197
|
@completed = Story.make(:completed)
|
176
198
|
@iteration = @story.iteration
|
177
199
|
end
|
178
|
-
|
200
|
+
|
179
201
|
should "only find stories that are assigned to an iteration" do
|
180
202
|
assert_equal @story, Story.for_iteration(@iteration.id).first
|
181
203
|
end
|
182
|
-
|
204
|
+
|
183
205
|
should "only find stories that are unassigned" do
|
184
206
|
assert_equal @story, Story.unassigned.first
|
185
207
|
end
|
186
|
-
|
208
|
+
|
187
209
|
should "only find stories that are in progress" do
|
188
210
|
assert_equal @in_progress, Story.in_progress.first
|
189
211
|
end
|
190
|
-
|
212
|
+
|
191
213
|
should "only find stories that are completed" do
|
192
214
|
assert_equal @completed, Story.completed.first
|
193
215
|
end
|
194
216
|
end
|
195
|
-
|
217
|
+
|
196
218
|
end
|
197
|
-
|
219
|
+
|
198
220
|
end
|
199
221
|
|
@@ -2,11 +2,17 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
2
2
|
|
3
3
|
class UserTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
should have_many :stories
|
6
|
+
should have_many(:iterations).through(:participations)
|
7
|
+
should have_many :participations
|
8
|
+
|
9
9
|
context "the User class" do
|
10
|
+
|
11
|
+
should "have a ROLES array in a constant" do
|
12
|
+
assert_equal(["admin", "developer", "customer"], User::ROLES)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
10
16
|
should "create_user" do
|
11
17
|
assert_difference 'User.count' do
|
12
18
|
user = User.make
|
@@ -50,14 +56,197 @@ class UserTest < ActiveSupport::TestCase
|
|
50
56
|
end
|
51
57
|
end
|
52
58
|
end
|
59
|
+
|
60
|
+
context "state machine transitions" do
|
61
|
+
setup do
|
62
|
+
@user = User.new
|
63
|
+
end
|
64
|
+
|
65
|
+
should "start life in the state 'pending'" do
|
66
|
+
assert_equal("active", @user.state)
|
67
|
+
end
|
68
|
+
|
69
|
+
context "on activate" do
|
70
|
+
context "from state :pending" do
|
71
|
+
setup do
|
72
|
+
@user.state = "pending"
|
73
|
+
@user.activate
|
74
|
+
end
|
75
|
+
|
76
|
+
should "set the user's state to 'activated'" do
|
77
|
+
assert_equal("active", @user.state)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "from state :suspended" do
|
82
|
+
setup do
|
83
|
+
@user.state = "suspended"
|
84
|
+
@user.activate
|
85
|
+
end
|
86
|
+
|
87
|
+
should "set the user's state to 'activated'" do
|
88
|
+
assert_equal("active", @user.state)
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
context "from state :deleted" do
|
94
|
+
setup do
|
95
|
+
@user.state = "deleted"
|
96
|
+
end
|
97
|
+
|
98
|
+
should "raise an invalid transition exception" do
|
99
|
+
assert_raise AASM::InvalidTransition do
|
100
|
+
@user.activate
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
should "leave the user's state as 'deleted'" do
|
105
|
+
assert_equal("deleted", @user.state)
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context "on :suspend" do
|
112
|
+
context "from state :pending" do
|
113
|
+
setup do
|
114
|
+
@user.state = "pending"
|
115
|
+
@user.suspend
|
116
|
+
end
|
117
|
+
|
118
|
+
should "set the user's state to 'suspended'" do
|
119
|
+
assert_equal("suspended", @user.state)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context "from state :active" do
|
124
|
+
setup do
|
125
|
+
@user.state = "active"
|
126
|
+
@user.suspend
|
127
|
+
end
|
128
|
+
|
129
|
+
should "set the user's state to 'suspended'" do
|
130
|
+
assert_equal("suspended", @user.state)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
context "from state :suspended" do
|
135
|
+
setup do
|
136
|
+
@user.state = "suspended"
|
137
|
+
end
|
138
|
+
|
139
|
+
should "raise an invalid transition exception" do
|
140
|
+
assert_raise AASM::InvalidTransition do
|
141
|
+
@user.suspend
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "from state :deleted" do
|
147
|
+
setup do
|
148
|
+
@user.state = "deleted"
|
149
|
+
end
|
150
|
+
|
151
|
+
should "raise an invalid transition exception" do
|
152
|
+
assert_raise AASM::InvalidTransition do
|
153
|
+
@user.suspend
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
context "on :delete" do
|
160
|
+
context "from state :pending" do
|
161
|
+
setup do
|
162
|
+
@user.state = "pending"
|
163
|
+
@user.delete
|
164
|
+
end
|
165
|
+
|
166
|
+
should "set the user's state to 'deleted'" do
|
167
|
+
assert_equal("deleted", @user.state)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context "from state :active" do
|
172
|
+
setup do
|
173
|
+
@user.state = "active"
|
174
|
+
@user.delete
|
175
|
+
end
|
176
|
+
|
177
|
+
should "set the user's state to 'deleted'" do
|
178
|
+
assert_equal("deleted", @user.state)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
context "from state :suspended" do
|
183
|
+
setup do
|
184
|
+
@user.state = "suspended"
|
185
|
+
@user.delete
|
186
|
+
end
|
187
|
+
|
188
|
+
should "set the user's state to 'deleted'" do
|
189
|
+
assert_equal("deleted", @user.state)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "from state :deleted" do
|
194
|
+
setup do
|
195
|
+
@user.state = "deleted"
|
196
|
+
end
|
197
|
+
|
198
|
+
should "raise an invalid transition exception" do
|
199
|
+
assert_raise AASM::InvalidTransition do
|
200
|
+
@user.delete
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
53
206
|
end
|
54
207
|
|
208
|
+
|
209
|
+
|
55
210
|
context "A user called quentin" do
|
56
211
|
|
57
212
|
setup do
|
58
213
|
@quentin = User.make(:quentin)
|
59
214
|
end
|
60
|
-
|
215
|
+
|
216
|
+
should "have the role 'customer'" do
|
217
|
+
assert @quentin.has_role?("customer")
|
218
|
+
end
|
219
|
+
|
220
|
+
context "when setting the user's role" do
|
221
|
+
context "to some non-existent role" do
|
222
|
+
setup do
|
223
|
+
@quentin.role = "something that doesn't exist"
|
224
|
+
end
|
225
|
+
|
226
|
+
should "not allow setting of role to something not in ROLES constant" do
|
227
|
+
assert_raise(ActiveRecord::RecordInvalid) do
|
228
|
+
@quentin.save!
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
context "to a different, existing role" do
|
233
|
+
setup do
|
234
|
+
@quentin.role = "admin"
|
235
|
+
end
|
236
|
+
|
237
|
+
should "allow the role to be set" do
|
238
|
+
assert_nothing_raised do
|
239
|
+
@quentin.save!
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
should "not have the role 'admin'" do
|
247
|
+
assert !@quentin.has_role?("admin")
|
248
|
+
end
|
249
|
+
|
61
250
|
should "print its login when to_s is called" do
|
62
251
|
assert_equal "quentin", @quentin.to_s
|
63
252
|
end
|
@@ -114,6 +303,7 @@ class UserTest < ActiveSupport::TestCase
|
|
114
303
|
assert_not_nil @quentin.remember_token_expires_at
|
115
304
|
assert @quentin.remember_token_expires_at.between?(before, after)
|
116
305
|
end
|
306
|
+
|
117
307
|
end
|
118
308
|
end
|
119
309
|
|