integrity 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +7 -0
- data/Rakefile +59 -132
- data/VERSION.yml +1 -1
- data/config/config.ru +29 -0
- data/config/config.sample.ru +6 -16
- data/config/config.sample.yml +15 -12
- data/config/config.yml +34 -0
- data/lib/integrity.rb +13 -13
- data/lib/integrity/app.rb +138 -0
- data/lib/integrity/author.rb +39 -0
- data/lib/integrity/build.rb +54 -31
- data/lib/integrity/commit.rb +71 -0
- data/lib/integrity/helpers.rb +3 -3
- data/lib/integrity/helpers/authorization.rb +2 -2
- data/lib/integrity/helpers/forms.rb +3 -3
- data/lib/integrity/helpers/pretty_output.rb +1 -1
- data/lib/integrity/helpers/rendering.rb +6 -1
- data/lib/integrity/helpers/resources.rb +9 -3
- data/lib/integrity/helpers/urls.rb +15 -13
- data/lib/integrity/installer.rb +45 -56
- data/lib/integrity/migrations.rb +31 -48
- data/lib/integrity/notifier.rb +14 -16
- data/lib/integrity/notifier/base.rb +29 -19
- data/lib/integrity/notifier/test_helpers.rb +100 -0
- data/lib/integrity/project.rb +69 -33
- data/lib/integrity/project_builder.rb +23 -14
- data/lib/integrity/scm/git.rb +15 -14
- data/lib/integrity/scm/git/uri.rb +9 -9
- data/test/acceptance/api_test.rb +97 -0
- data/test/acceptance/browse_project_builds_test.rb +65 -0
- data/test/acceptance/browse_project_test.rb +95 -0
- data/test/acceptance/build_notifications_test.rb +42 -0
- data/test/acceptance/create_project_test.rb +97 -0
- data/test/acceptance/delete_project_test.rb +53 -0
- data/test/acceptance/edit_project_test.rb +117 -0
- data/test/acceptance/error_page_test.rb +18 -0
- data/test/acceptance/helpers.rb +2 -0
- data/test/acceptance/installer_test.rb +62 -0
- data/test/acceptance/manual_build_project_test.rb +82 -0
- data/test/acceptance/notifier_test.rb +109 -0
- data/test/acceptance/project_syndication_test.rb +30 -0
- data/test/acceptance/stylesheet_test.rb +18 -0
- data/test/helpers.rb +59 -26
- data/test/helpers/acceptance.rb +19 -65
- data/test/helpers/acceptance/email_notifier.rb +55 -0
- data/test/helpers/acceptance/git_helper.rb +15 -15
- data/test/helpers/acceptance/textfile_notifier.rb +3 -3
- data/test/helpers/expectations.rb +0 -1
- data/test/helpers/expectations/be_a.rb +4 -4
- data/test/helpers/expectations/change.rb +5 -5
- data/test/helpers/expectations/have.rb +4 -4
- data/test/helpers/expectations/predicates.rb +4 -4
- data/test/helpers/fixtures.rb +44 -18
- data/test/helpers/initial_migration_fixture.sql +44 -0
- data/test/unit/build_test.rb +51 -0
- data/test/unit/commit_test.rb +83 -0
- data/test/unit/helpers_test.rb +56 -0
- data/test/unit/integrity_test.rb +18 -0
- data/test/unit/migrations_test.rb +56 -0
- data/test/unit/notifier_test.rb +123 -0
- data/test/unit/project_builder_test.rb +108 -0
- data/test/unit/project_test.rb +282 -0
- data/test/unit/scm_test.rb +54 -0
- data/vendor/webrat/History.txt +306 -0
- data/vendor/webrat/MIT-LICENSE.txt +19 -0
- data/vendor/webrat/README.rdoc +85 -0
- data/vendor/webrat/Rakefile +151 -0
- data/vendor/webrat/install.rb +1 -0
- data/vendor/webrat/lib/webrat.rb +34 -0
- data/vendor/webrat/lib/webrat/core.rb +14 -0
- data/vendor/webrat/lib/webrat/core/configuration.rb +98 -0
- data/vendor/webrat/lib/webrat/core/elements/area.rb +31 -0
- data/vendor/webrat/lib/webrat/core/elements/element.rb +33 -0
- data/vendor/webrat/lib/webrat/core/elements/field.rb +403 -0
- data/vendor/webrat/lib/webrat/core/elements/form.rb +103 -0
- data/vendor/webrat/lib/webrat/core/elements/label.rb +31 -0
- data/vendor/webrat/lib/webrat/core/elements/link.rb +90 -0
- data/vendor/webrat/lib/webrat/core/elements/select_option.rb +35 -0
- data/vendor/webrat/lib/webrat/core/locators.rb +20 -0
- data/vendor/webrat/lib/webrat/core/locators/area_locator.rb +38 -0
- data/vendor/webrat/lib/webrat/core/locators/button_locator.rb +54 -0
- data/vendor/webrat/lib/webrat/core/locators/field_by_id_locator.rb +37 -0
- data/vendor/webrat/lib/webrat/core/locators/field_labeled_locator.rb +56 -0
- data/vendor/webrat/lib/webrat/core/locators/field_locator.rb +25 -0
- data/vendor/webrat/lib/webrat/core/locators/field_named_locator.rb +41 -0
- data/vendor/webrat/lib/webrat/core/locators/form_locator.rb +19 -0
- data/vendor/webrat/lib/webrat/core/locators/label_locator.rb +34 -0
- data/vendor/webrat/lib/webrat/core/locators/link_locator.rb +66 -0
- data/vendor/webrat/lib/webrat/core/locators/locator.rb +20 -0
- data/vendor/webrat/lib/webrat/core/locators/select_option_locator.rb +59 -0
- data/vendor/webrat/lib/webrat/core/logging.rb +21 -0
- data/vendor/webrat/lib/webrat/core/matchers.rb +4 -0
- data/vendor/webrat/lib/webrat/core/matchers/have_content.rb +73 -0
- data/vendor/webrat/lib/webrat/core/matchers/have_selector.rb +74 -0
- data/vendor/webrat/lib/webrat/core/matchers/have_tag.rb +21 -0
- data/vendor/webrat/lib/webrat/core/matchers/have_xpath.rb +147 -0
- data/vendor/webrat/lib/webrat/core/methods.rb +61 -0
- data/vendor/webrat/lib/webrat/core/mime.rb +29 -0
- data/vendor/webrat/lib/webrat/core/save_and_open_page.rb +50 -0
- data/vendor/webrat/lib/webrat/core/scope.rb +350 -0
- data/vendor/webrat/lib/webrat/core/session.rb +281 -0
- data/vendor/webrat/lib/webrat/core/xml.rb +115 -0
- data/vendor/webrat/lib/webrat/core/xml/hpricot.rb +19 -0
- data/vendor/webrat/lib/webrat/core/xml/nokogiri.rb +76 -0
- data/vendor/webrat/lib/webrat/core/xml/rexml.rb +24 -0
- data/vendor/webrat/lib/webrat/core_extensions/blank.rb +58 -0
- data/vendor/webrat/lib/webrat/core_extensions/deprecate.rb +8 -0
- data/vendor/webrat/lib/webrat/core_extensions/detect_mapped.rb +12 -0
- data/vendor/webrat/lib/webrat/core_extensions/meta_class.rb +6 -0
- data/vendor/webrat/lib/webrat/core_extensions/nil_to_param.rb +5 -0
- data/vendor/webrat/lib/webrat/mechanize.rb +74 -0
- data/vendor/webrat/lib/webrat/merb.rb +9 -0
- data/vendor/webrat/lib/webrat/merb_session.rb +65 -0
- data/vendor/webrat/lib/webrat/rack.rb +24 -0
- data/vendor/webrat/lib/webrat/rails.rb +105 -0
- data/vendor/webrat/lib/webrat/rspec-rails.rb +13 -0
- data/vendor/webrat/lib/webrat/selenium.rb +154 -0
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/button.js +12 -0
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/label.js +16 -0
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webrat.js +5 -0
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlink.js +9 -0
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js +15 -0
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js +5 -0
- data/vendor/webrat/lib/webrat/selenium/matchers.rb +4 -0
- data/vendor/webrat/lib/webrat/selenium/matchers/have_content.rb +66 -0
- data/vendor/webrat/lib/webrat/selenium/matchers/have_selector.rb +49 -0
- data/vendor/webrat/lib/webrat/selenium/matchers/have_tag.rb +72 -0
- data/vendor/webrat/lib/webrat/selenium/matchers/have_xpath.rb +45 -0
- data/vendor/webrat/lib/webrat/selenium/selenium_extensions.js +6 -0
- data/vendor/webrat/lib/webrat/selenium/selenium_session.rb +247 -0
- data/vendor/webrat/lib/webrat/sinatra.rb +44 -0
- data/vendor/webrat/spec/fakes/test_session.rb +34 -0
- data/vendor/webrat/spec/integration/merb/Rakefile +35 -0
- data/vendor/webrat/spec/integration/merb/app/controllers/application.rb +2 -0
- data/vendor/webrat/spec/integration/merb/app/controllers/exceptions.rb +13 -0
- data/vendor/webrat/spec/integration/merb/app/controllers/testing.rb +18 -0
- data/vendor/webrat/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/vendor/webrat/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
- data/vendor/webrat/spec/integration/merb/app/views/layout/application.html.erb +12 -0
- data/vendor/webrat/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
- data/vendor/webrat/spec/integration/merb/config/environments/development.rb +15 -0
- data/vendor/webrat/spec/integration/merb/config/environments/rake.rb +11 -0
- data/vendor/webrat/spec/integration/merb/config/environments/test.rb +14 -0
- data/vendor/webrat/spec/integration/merb/config/init.rb +25 -0
- data/vendor/webrat/spec/integration/merb/config/rack.rb +11 -0
- data/vendor/webrat/spec/integration/merb/config/router.rb +33 -0
- data/vendor/webrat/spec/integration/merb/spec/spec.opts +1 -0
- data/vendor/webrat/spec/integration/merb/spec/spec_helper.rb +24 -0
- data/vendor/webrat/spec/integration/merb/spec/webrat_spec.rb +32 -0
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/app_script.rb +31 -0
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/common.rb +64 -0
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/gem_ext.rb +124 -0
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/ops.rb +93 -0
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/utils.rb +40 -0
- data/vendor/webrat/spec/integration/rails/Rakefile +30 -0
- data/vendor/webrat/spec/integration/rails/app/controllers/application.rb +15 -0
- data/vendor/webrat/spec/integration/rails/app/controllers/webrat_controller.rb +39 -0
- data/vendor/webrat/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
- data/vendor/webrat/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
- data/vendor/webrat/spec/integration/rails/config/boot.rb +109 -0
- data/vendor/webrat/spec/integration/rails/config/environment.rb +12 -0
- data/vendor/webrat/spec/integration/rails/config/environments/development.rb +17 -0
- data/vendor/webrat/spec/integration/rails/config/environments/selenium.rb +22 -0
- data/vendor/webrat/spec/integration/rails/config/environments/test.rb +22 -0
- data/vendor/webrat/spec/integration/rails/config/initializers/inflections.rb +10 -0
- data/vendor/webrat/spec/integration/rails/config/initializers/mime_types.rb +5 -0
- data/vendor/webrat/spec/integration/rails/config/initializers/new_rails_defaults.rb +17 -0
- data/vendor/webrat/spec/integration/rails/config/locales/en.yml +5 -0
- data/vendor/webrat/spec/integration/rails/config/routes.rb +14 -0
- data/vendor/webrat/spec/integration/rails/public/404.html +30 -0
- data/vendor/webrat/spec/integration/rails/public/422.html +30 -0
- data/vendor/webrat/spec/integration/rails/public/500.html +33 -0
- data/vendor/webrat/spec/integration/rails/script/about +4 -0
- data/vendor/webrat/spec/integration/rails/script/console +3 -0
- data/vendor/webrat/spec/integration/rails/script/dbconsole +3 -0
- data/vendor/webrat/spec/integration/rails/script/destroy +3 -0
- data/vendor/webrat/spec/integration/rails/script/generate +3 -0
- data/vendor/webrat/spec/integration/rails/script/performance/benchmarker +3 -0
- data/vendor/webrat/spec/integration/rails/script/performance/profiler +3 -0
- data/vendor/webrat/spec/integration/rails/script/performance/request +3 -0
- data/vendor/webrat/spec/integration/rails/script/plugin +3 -0
- data/vendor/webrat/spec/integration/rails/script/process/inspector +3 -0
- data/vendor/webrat/spec/integration/rails/script/process/reaper +3 -0
- data/vendor/webrat/spec/integration/rails/script/process/spawner +3 -0
- data/vendor/webrat/spec/integration/rails/script/runner +3 -0
- data/vendor/webrat/spec/integration/rails/script/server +3 -0
- data/vendor/webrat/spec/integration/rails/test/integration/webrat_test.rb +80 -0
- data/vendor/webrat/spec/integration/rails/test/test_helper.rb +25 -0
- data/vendor/webrat/spec/integration/sinatra/Rakefile +5 -0
- data/vendor/webrat/spec/integration/sinatra/classic_app.rb +64 -0
- data/vendor/webrat/spec/integration/sinatra/modular_app.rb +16 -0
- data/vendor/webrat/spec/integration/sinatra/test/classic_app_test.rb +37 -0
- data/vendor/webrat/spec/integration/sinatra/test/modular_app_test.rb +18 -0
- data/vendor/webrat/spec/integration/sinatra/test/test_helper.rb +16 -0
- data/vendor/webrat/spec/private/core/configuration_spec.rb +104 -0
- data/vendor/webrat/spec/private/core/field_spec.rb +67 -0
- data/vendor/webrat/spec/private/core/link_spec.rb +24 -0
- data/vendor/webrat/spec/private/core/logging_spec.rb +10 -0
- data/vendor/webrat/spec/private/core/session_spec.rb +198 -0
- data/vendor/webrat/spec/private/mechanize/mechanize_session_spec.rb +81 -0
- data/vendor/webrat/spec/private/merb/merb_session_spec.rb +42 -0
- data/vendor/webrat/spec/private/nokogiri_spec.rb +77 -0
- data/vendor/webrat/spec/private/rails/attaches_file_spec.rb +81 -0
- data/vendor/webrat/spec/private/rails/rails_session_spec.rb +110 -0
- data/vendor/webrat/spec/private/selenium/selenium_session_spec.rb +44 -0
- data/vendor/webrat/spec/private/selenium/selenium_spec.rb +109 -0
- data/vendor/webrat/spec/public/basic_auth_spec.rb +24 -0
- data/vendor/webrat/spec/public/check_spec.rb +191 -0
- data/vendor/webrat/spec/public/choose_spec.rb +118 -0
- data/vendor/webrat/spec/public/click_area_spec.rb +106 -0
- data/vendor/webrat/spec/public/click_button_spec.rb +502 -0
- data/vendor/webrat/spec/public/click_link_spec.rb +469 -0
- data/vendor/webrat/spec/public/fill_in_spec.rb +209 -0
- data/vendor/webrat/spec/public/locators/field_by_xpath_spec.rb +19 -0
- data/vendor/webrat/spec/public/locators/field_labeled_spec.rb +157 -0
- data/vendor/webrat/spec/public/locators/field_with_id_spec.rb +16 -0
- data/vendor/webrat/spec/public/matchers/contain_spec.rb +114 -0
- data/vendor/webrat/spec/public/matchers/have_selector_spec.rb +135 -0
- data/vendor/webrat/spec/public/matchers/have_tag_spec.rb +39 -0
- data/vendor/webrat/spec/public/matchers/have_xpath_spec.rb +123 -0
- data/vendor/webrat/spec/public/reload_spec.rb +10 -0
- data/vendor/webrat/spec/public/save_and_open_spec.rb +51 -0
- data/vendor/webrat/spec/public/select_date_spec.rb +88 -0
- data/vendor/webrat/spec/public/select_datetime_spec.rb +106 -0
- data/vendor/webrat/spec/public/select_spec.rb +246 -0
- data/vendor/webrat/spec/public/select_time_spec.rb +79 -0
- data/vendor/webrat/spec/public/set_hidden_field_spec.rb +5 -0
- data/vendor/webrat/spec/public/submit_form_spec.rb +5 -0
- data/vendor/webrat/spec/public/visit_spec.rb +58 -0
- data/vendor/webrat/spec/public/within_spec.rb +177 -0
- data/vendor/webrat/spec/rcov.opts +1 -0
- data/vendor/webrat/spec/spec.opts +2 -0
- data/vendor/webrat/spec/spec_helper.rb +50 -0
- data/vendor/webrat/vendor/selenium-server.jar +0 -0
- data/views/_commit_info.haml +24 -0
- data/views/build.haml +2 -2
- data/views/error.haml +4 -3
- data/views/home.haml +3 -5
- data/views/integrity.sass +19 -6
- data/views/new.haml +6 -6
- data/views/project.builder +9 -9
- data/views/project.haml +14 -12
- metadata +319 -124
- data/app.rb +0 -138
- data/integrity.gemspec +0 -76
- data/lib/integrity/core_ext/string.rb +0 -5
- data/test/helpers/expectations/have_tag.rb +0 -128
- data/views/_build_info.haml +0 -18
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helpers"
|
2
|
+
|
3
|
+
class ManualBuildProjectTest < Test::Unit::AcceptanceTestCase
|
4
|
+
story <<-EOS
|
5
|
+
As an administrator,
|
6
|
+
I want to manually build my project
|
7
|
+
So that I know if it builds properly
|
8
|
+
EOS
|
9
|
+
|
10
|
+
scenario "clicking on 'Manual Build' triggers a successful build" do
|
11
|
+
git_repo(:my_test_project).add_successful_commit
|
12
|
+
Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path)
|
13
|
+
login_as "admin", "test"
|
14
|
+
|
15
|
+
visit "/my-test-project"
|
16
|
+
click_button "manual build"
|
17
|
+
|
18
|
+
assert_have_tag("h1", :content =>
|
19
|
+
"Built #{git_repo(:my_test_project).short_head} successfully")
|
20
|
+
assert_have_tag("blockquote p", :content => "This commit will work")
|
21
|
+
assert_have_tag("span.who", :content => "by: John Doe")
|
22
|
+
assert_have_tag("span.when", :content => "today")
|
23
|
+
assert_have_tag("pre.output", :content => "Running tests...")
|
24
|
+
end
|
25
|
+
|
26
|
+
scenario "clicking on 'Manual Build' triggers a failed build" do
|
27
|
+
git_repo(:my_test_project).add_failing_commit
|
28
|
+
Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path)
|
29
|
+
login_as "admin", "test"
|
30
|
+
|
31
|
+
visit "/my-test-project"
|
32
|
+
click_button "manual build"
|
33
|
+
|
34
|
+
assert_have_tag("h1",
|
35
|
+
:content => "Built #{git_repo(:my_test_project).short_head} and failed")
|
36
|
+
assert_have_tag("blockquote p", :content => "This commit will fail")
|
37
|
+
end
|
38
|
+
|
39
|
+
scenario "fixing the build command and then rebuilding result in a successful build" do
|
40
|
+
git_repo(:my_test_project).add_successful_commit
|
41
|
+
Project.gen(:my_test_project,
|
42
|
+
:uri => git_repo(:my_test_project).path,
|
43
|
+
:command => "ruby not-found.rb")
|
44
|
+
|
45
|
+
login_as "admin", "test"
|
46
|
+
|
47
|
+
visit "/my-test-project"
|
48
|
+
click_button "manual build"
|
49
|
+
assert_have_tag("h1", :content => "failed")
|
50
|
+
|
51
|
+
visit "/my-test-project/edit"
|
52
|
+
fill_in "Build script", :with => "./test"
|
53
|
+
click_button "Update Project"
|
54
|
+
|
55
|
+
visit "/my-test-project"
|
56
|
+
click_button "Build the last commit"
|
57
|
+
|
58
|
+
assert_have_tag("h1", :content => "success")
|
59
|
+
end
|
60
|
+
|
61
|
+
scenario "Successful builds should not display the 'Rebuild' button" do
|
62
|
+
git_repo(:my_test_project).add_successful_commit
|
63
|
+
Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path)
|
64
|
+
login_as "admin", "test"
|
65
|
+
|
66
|
+
visit "/my-test-project"
|
67
|
+
click_button "manual build"
|
68
|
+
|
69
|
+
assert_have_no_tag("button", :content => "Rebuild")
|
70
|
+
end
|
71
|
+
|
72
|
+
scenario "Failed builds should display the 'Rebuild' button" do
|
73
|
+
git_repo(:my_test_project).add_failing_commit
|
74
|
+
Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path)
|
75
|
+
login_as "admin", "test"
|
76
|
+
|
77
|
+
visit "/my-test-project"
|
78
|
+
click_button "manual build"
|
79
|
+
|
80
|
+
assert_have_tag("button", :content => "Rebuild")
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helpers"
|
2
|
+
|
3
|
+
class NotifierConfigIssues < Test::Unit::AcceptanceTestCase
|
4
|
+
story <<-EOS
|
5
|
+
As an administrator,
|
6
|
+
I want to add multiple projects to Integrity,
|
7
|
+
So that I can be certain notifiers remain functional (cf #43)
|
8
|
+
EOS
|
9
|
+
|
10
|
+
before(:each) do
|
11
|
+
# This is needed before any available notifier is unset
|
12
|
+
# in the global #before
|
13
|
+
load File.dirname(__FILE__) + "/../helpers/acceptance/email_notifier.rb"
|
14
|
+
end
|
15
|
+
|
16
|
+
def fill_in_email_notifier
|
17
|
+
fill_in "notifiers[Email][to]", :with => "quentin@example.com"
|
18
|
+
fill_in "notifiers[Email][from]", :with => "ci@example.com"
|
19
|
+
fill_in "notifiers[Email][user]", :with => "inspector"
|
20
|
+
fill_in "notifiers[Email][pass]", :with => "gadget"
|
21
|
+
fill_in "notifiers[Email][auth]", :with => "simple"
|
22
|
+
fill_in "notifiers[Email][domain]", :with => "example.com"
|
23
|
+
end
|
24
|
+
|
25
|
+
def fill_in_project_info(name, repo)
|
26
|
+
fill_in "Name", :with => name
|
27
|
+
fill_in "Git repository", :with => repo
|
28
|
+
fill_in "Branch to track", :with => "master"
|
29
|
+
fill_in "Build script", :with => "rake"
|
30
|
+
check "Public project"
|
31
|
+
|
32
|
+
fill_in_email_notifier
|
33
|
+
end
|
34
|
+
|
35
|
+
def assert_have_email_notifier
|
36
|
+
assert_have_tag "input#email_notifier_to[@value='quentin@example.com']"
|
37
|
+
assert_have_tag "input#email_notifier_from[@value='ci@example.com']"
|
38
|
+
assert_have_tag "input#email_notifier_user[@value='inspector']"
|
39
|
+
assert_have_tag "input#email_notifier_pass[@value='gadget']"
|
40
|
+
assert_have_tag "input#email_notifier_auth[@value='simple']"
|
41
|
+
assert_have_tag "input#email_notifier_domain[@value='example.com']"
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_project(name, repo)
|
45
|
+
visit "/new"
|
46
|
+
fill_in_project_info(name, repo)
|
47
|
+
click_button "Create Project"
|
48
|
+
|
49
|
+
assert_have_tag("h1", :content => name)
|
50
|
+
click_link 'Edit Project'
|
51
|
+
assert_have_email_notifier
|
52
|
+
end
|
53
|
+
|
54
|
+
def edit_project(name)
|
55
|
+
visit "/#{name}"
|
56
|
+
click_link "Edit Project"
|
57
|
+
assert_have_email_notifier
|
58
|
+
fill_in :branch, :with => "testing"
|
59
|
+
click_button "Update Project"
|
60
|
+
end
|
61
|
+
|
62
|
+
scenario "an admin can create a public project and retain mailer info" do
|
63
|
+
Project.first(:permalink => "integrity").should be_nil
|
64
|
+
|
65
|
+
login_as "admin", "test"
|
66
|
+
|
67
|
+
visit "/"
|
68
|
+
add_project "Integrity", "git://github.com/foca/integrity.git"
|
69
|
+
edit_project "integrity"
|
70
|
+
|
71
|
+
visit "/integrity"
|
72
|
+
click_link "Edit Project"
|
73
|
+
|
74
|
+
assert_have_email_notifier
|
75
|
+
end
|
76
|
+
|
77
|
+
scenario "an admin can create multiple public projects" do
|
78
|
+
Project.first(:permalink => "integrity").should be_nil
|
79
|
+
|
80
|
+
login_as "admin", "test"
|
81
|
+
|
82
|
+
visit "/"
|
83
|
+
|
84
|
+
add_project "Integrity", "git://github.com/foca/integrity.git"
|
85
|
+
click_link "projects"
|
86
|
+
|
87
|
+
add_project "Webrat", "git://github.com/brynary/webrat.git"
|
88
|
+
click_link "projects"
|
89
|
+
|
90
|
+
add_project "Rails", "git://github.com/rails/rails.git"
|
91
|
+
click_link "projects"
|
92
|
+
|
93
|
+
edit_project "integrity"
|
94
|
+
edit_project "webrat"
|
95
|
+
edit_project "rails"
|
96
|
+
|
97
|
+
visit "/integrity"
|
98
|
+
click_link "Edit Project"
|
99
|
+
assert_have_email_notifier
|
100
|
+
|
101
|
+
visit "/webrat"
|
102
|
+
click_link "Edit Project"
|
103
|
+
assert_have_email_notifier
|
104
|
+
|
105
|
+
visit "/rails"
|
106
|
+
click_link "Edit Project"
|
107
|
+
assert_have_email_notifier
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helpers"
|
2
|
+
|
3
|
+
class ProjectSyndicationTest < Test::Unit::AcceptanceTestCase
|
4
|
+
story <<-EOS
|
5
|
+
As a user,
|
6
|
+
I want to subscribe to a public project's Atom feed
|
7
|
+
So I can know the status of my favorite projects while having my morning coffee
|
8
|
+
EOS
|
9
|
+
|
10
|
+
scenario "a public project's page includes an autodiscovery link tag for the feed" do
|
11
|
+
Project.gen(:integrity, :public => true)
|
12
|
+
visit "/integrity"
|
13
|
+
|
14
|
+
assert_have_tag("link[@href='/integrity.atom']")
|
15
|
+
end
|
16
|
+
|
17
|
+
scenario "a public project's feed should include the latest builds" do
|
18
|
+
commits = 10.of { Commit.gen(:successful) } + 1.of { Commit.gen(:failed) }
|
19
|
+
Project.gen(:integrity, :public => true, :commits => commits)
|
20
|
+
|
21
|
+
visit "/integrity.atom"
|
22
|
+
|
23
|
+
# TODO: check for content-type
|
24
|
+
|
25
|
+
assert_have_tag("feed title", :content => "Build history for Integrity")
|
26
|
+
assert_have_tag("feed entry", :count => 11)
|
27
|
+
assert_have_tag("feed entry:first title", :content => "success")
|
28
|
+
assert_have_tag("feed entry:last title", :content => "failed")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/helpers"
|
2
|
+
|
3
|
+
class IntegrityStylesheetTest < Test::Unit::AcceptanceTestCase
|
4
|
+
story <<-EOS
|
5
|
+
As a user,
|
6
|
+
I want the stylesheet to work (even with Sinatra 0.9.1)
|
7
|
+
So that Integrity isn't a PITA to use
|
8
|
+
EOS
|
9
|
+
|
10
|
+
scenario "browsing on some Integrity install" do
|
11
|
+
visit "/integrity.css"
|
12
|
+
|
13
|
+
assert_contain("body {")
|
14
|
+
# TODO: better test
|
15
|
+
assert_equal %Q{"2465c472aacf302259dde5146a841e45"},
|
16
|
+
webrat_session.send(:response).headers["ETag"]
|
17
|
+
end
|
18
|
+
end
|
data/test/helpers.rb
CHANGED
@@ -1,37 +1,43 @@
|
|
1
|
-
|
1
|
+
$:.unshift File.dirname(__FILE__) + "/../lib", File.dirname(__FILE__),
|
2
|
+
File.dirname(__FILE__) + "/../vendor/webrat/lib"
|
3
|
+
|
4
|
+
%w(test/unit
|
5
|
+
context
|
6
|
+
pending
|
7
|
+
matchy
|
8
|
+
storyteller
|
9
|
+
webrat/sinatra
|
10
|
+
rr
|
11
|
+
mocha
|
12
|
+
test/zentest_assertions
|
13
|
+
dm-sweatshop).each { |dependency|
|
14
|
+
begin
|
15
|
+
require dependency
|
16
|
+
rescue LoadError
|
17
|
+
puts "You're missing some gems required to run the tests."
|
18
|
+
puts "Please run `rake test:install_dependencies`"
|
19
|
+
puts "You'll probably need to run that command as root or with sudo."
|
20
|
+
|
21
|
+
puts "Thanks :)"
|
22
|
+
puts
|
23
|
+
|
24
|
+
exit 1
|
25
|
+
end
|
26
|
+
}
|
2
27
|
|
3
28
|
begin
|
4
|
-
require "test/unit"
|
5
|
-
require "redgreen"
|
6
|
-
require "context"
|
7
|
-
require "storyteller"
|
8
|
-
require "pending"
|
9
|
-
require "matchy"
|
10
|
-
require "rr"
|
11
|
-
require "mocha"
|
12
29
|
require "ruby-debug"
|
30
|
+
require "redgreen"
|
13
31
|
rescue LoadError
|
14
|
-
puts "You're missing some gems required to run the tests."
|
15
|
-
puts "Please run `rake test:install_dependencies`"
|
16
|
-
puts "You'll probably need to run that command as root or with sudo."
|
17
|
-
puts
|
18
|
-
puts "Thanks :)"
|
19
|
-
puts
|
20
|
-
|
21
|
-
exit 1
|
22
32
|
end
|
23
33
|
|
24
|
-
require
|
25
|
-
require
|
34
|
+
require "integrity"
|
35
|
+
require "helpers/expectations"
|
36
|
+
require "helpers/fixtures"
|
26
37
|
|
27
38
|
module TestHelper
|
28
|
-
def setup_and_reset_database!
|
29
|
-
DataMapper.setup(:default, "sqlite3::memory:")
|
30
|
-
DataMapper.auto_migrate!
|
31
|
-
end
|
32
|
-
|
33
39
|
def ignore_logs!
|
34
|
-
|
40
|
+
Integrity.config[:log] = "/tmp/integrity.test.log"
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
@@ -43,5 +49,32 @@ class Test::Unit::TestCase
|
|
43
49
|
include RR::Adapters::TestUnit
|
44
50
|
include Integrity
|
45
51
|
include TestHelper
|
46
|
-
end
|
47
52
|
|
53
|
+
before(:all) do
|
54
|
+
DataMapper.setup(:default, "sqlite3::memory:")
|
55
|
+
end
|
56
|
+
|
57
|
+
before(:each) do
|
58
|
+
RR.reset
|
59
|
+
DataMapper.auto_migrate!
|
60
|
+
Integrity.instance_variable_set(:@config, nil)
|
61
|
+
Notifier.available.each { |n|
|
62
|
+
Notifier.send(:remove_const, n.to_s.split(":").last.to_sym)
|
63
|
+
}
|
64
|
+
|
65
|
+
repository(:default) do
|
66
|
+
transaction = DataMapper::Transaction.new(repository)
|
67
|
+
transaction.begin
|
68
|
+
repository.adapter.push_transaction(transaction)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
after(:each) do
|
73
|
+
repository(:default) do
|
74
|
+
while repository.adapter.current_transaction
|
75
|
+
repository.adapter.current_transaction.rollback
|
76
|
+
repository.adapter.pop_transaction
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/test/helpers/acceptance.rb
CHANGED
@@ -1,67 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require 'sinatra'
|
3
|
-
require 'sinatra/test'
|
4
|
-
|
5
|
-
set :environment, :test
|
6
|
-
disable :run
|
7
|
-
disable :reload
|
8
|
-
|
9
|
-
Webrat.configuration.instance_variable_set("@mode", :sinatra)
|
10
|
-
|
11
|
-
module Webrat
|
12
|
-
class SinatraSession < Session
|
13
|
-
DEFAULT_DOMAIN = "integrity.example.org"
|
14
|
-
|
15
|
-
def initialize(context = nil)
|
16
|
-
super(context)
|
17
|
-
@sinatra_test = Sinatra::TestHarness.new
|
18
|
-
end
|
19
|
-
|
20
|
-
%w(get head post put delete).each do |verb|
|
21
|
-
class_eval <<-METHOD
|
22
|
-
def #{verb}(path, data, headers = {})
|
23
|
-
params = data.inject({}) do |data, (key,value)|
|
24
|
-
data[key] = Rack::Utils.unescape(value)
|
25
|
-
data
|
26
|
-
end
|
27
|
-
headers['HTTP_HOST'] = DEFAULT_DOMAIN
|
28
|
-
@sinatra_test.#{verb}(path, params, headers)
|
29
|
-
end
|
30
|
-
METHOD
|
31
|
-
end
|
32
|
-
|
33
|
-
def response_body
|
34
|
-
@sinatra_test.body
|
35
|
-
end
|
36
|
-
|
37
|
-
def response_code
|
38
|
-
@sinatra_test.status
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def response
|
44
|
-
@sinatra_test.response
|
45
|
-
end
|
46
|
-
|
47
|
-
def current_host
|
48
|
-
URI.parse(current_url).host || DEFAULT_DOMAIN
|
49
|
-
end
|
50
|
-
|
51
|
-
def response_location_host
|
52
|
-
URI.parse(response_location).host || DEFAULT_DOMAIN
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
require Integrity.root / "app"
|
58
|
-
require File.dirname(__FILE__) / "acceptance/git_helper"
|
1
|
+
require "helpers/acceptance/git_helper"
|
59
2
|
|
60
3
|
module AcceptanceHelper
|
61
4
|
include FileUtils
|
62
5
|
|
63
6
|
def export_directory
|
64
|
-
|
7
|
+
File.dirname(__FILE__) + "/../../exports"
|
65
8
|
end
|
66
9
|
|
67
10
|
def enable_auth!
|
@@ -75,7 +18,7 @@ module AcceptanceHelper
|
|
75
18
|
def AcceptanceHelper.logged_in; true; end
|
76
19
|
basic_auth user, password
|
77
20
|
visit "/login"
|
78
|
-
|
21
|
+
Integrity::App.before { login_required if AcceptanceHelper.logged_in }
|
79
22
|
end
|
80
23
|
|
81
24
|
def log_out
|
@@ -94,9 +37,9 @@ module AcceptanceHelper
|
|
94
37
|
end
|
95
38
|
|
96
39
|
def setup_log!
|
97
|
-
|
98
|
-
|
99
|
-
Integrity.config[:log] =
|
40
|
+
log_file = Pathname(File.dirname(__FILE__) + "/../../integrity.log")
|
41
|
+
log_file.delete if log_file.exist?
|
42
|
+
Integrity.config[:log] = log_file
|
100
43
|
end
|
101
44
|
end
|
102
45
|
|
@@ -105,15 +48,25 @@ class Test::Unit::AcceptanceTestCase < Test::Unit::TestCase
|
|
105
48
|
include Test::Storyteller
|
106
49
|
include GitHelper
|
107
50
|
include Webrat::Methods
|
51
|
+
include Webrat::Matchers
|
52
|
+
include Webrat::HaveTagMatcher
|
53
|
+
|
54
|
+
# TODO: does this belongs in Webrat::SinatraSession?
|
108
55
|
Webrat::Methods.delegate_to_session :response_code
|
109
56
|
|
57
|
+
def app
|
58
|
+
Integrity::App.tap { |app|
|
59
|
+
app.set :environment, :test
|
60
|
+
app.disable :raise_errors, :run, :reload
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
110
64
|
before(:all) do
|
111
|
-
Integrity.config[:base_uri] = "http
|
65
|
+
Integrity.config[:base_uri] = "http://www.example.com"
|
112
66
|
end
|
113
67
|
|
114
68
|
before(:each) do
|
115
69
|
# ensure each scenario is run in a clean sandbox
|
116
|
-
setup_and_reset_database!
|
117
70
|
enable_auth!
|
118
71
|
setup_log!
|
119
72
|
set_and_create_export_directory!
|
@@ -124,4 +77,5 @@ class Test::Unit::AcceptanceTestCase < Test::Unit::TestCase
|
|
124
77
|
destroy_all_git_repos
|
125
78
|
rm_r export_directory if File.directory?(export_directory)
|
126
79
|
end
|
80
|
+
|
127
81
|
end
|