integrity 0.1.9 → 0.1.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +57 -31
- data/config/heroku/.gems +4 -0
- data/config/heroku/Rakefile +6 -0
- data/config/heroku/config.ru +7 -0
- data/config/heroku/integrity-config.rb +11 -0
- data/integrity.gemspec +123 -0
- data/lib/integrity.rb +7 -14
- data/lib/integrity/installer.rb +45 -35
- data/lib/integrity/notifier/test.rb +59 -0
- data/lib/integrity/notifier/test/fixtures.rb +108 -0
- data/lib/integrity/notifier/test/hpricot_matcher.rb +38 -0
- data/test/acceptance/build_notifications_test.rb +2 -2
- data/test/acceptance/installer_test.rb +25 -7
- data/test/helpers.rb +1 -1
- data/test/helpers/acceptance.rb +1 -4
- data/test/helpers/fixtures.rb +0 -22
- data/test/unit/notifier/test_test.rb +29 -0
- data/test/unit/project_builder_test.rb +4 -1
- data/vendor/sinatra-ditties/README.rdoc +3 -0
- data/vendor/sinatra-ditties/lib/sinatra/ditties.rb +12 -0
- data/vendor/sinatra-ditties/lib/sinatra/ditties/authorization.rb +61 -0
- data/vendor/sinatra-ditties/lib/sinatra/ditties/mailer.rb +146 -0
- metadata +79 -318
- data/VERSION.yml +0 -4
- data/config/config.ru +0 -29
- data/config/config.yml +0 -34
- data/lib/integrity/notifier/test_helpers.rb +0 -100
- data/vendor/webrat/History.txt +0 -306
- data/vendor/webrat/MIT-LICENSE.txt +0 -19
- data/vendor/webrat/README.rdoc +0 -85
- data/vendor/webrat/Rakefile +0 -151
- data/vendor/webrat/install.rb +0 -1
- data/vendor/webrat/lib/webrat.rb +0 -34
- data/vendor/webrat/lib/webrat/core.rb +0 -14
- data/vendor/webrat/lib/webrat/core/configuration.rb +0 -98
- data/vendor/webrat/lib/webrat/core/elements/area.rb +0 -31
- data/vendor/webrat/lib/webrat/core/elements/element.rb +0 -33
- data/vendor/webrat/lib/webrat/core/elements/field.rb +0 -403
- data/vendor/webrat/lib/webrat/core/elements/form.rb +0 -103
- data/vendor/webrat/lib/webrat/core/elements/label.rb +0 -31
- data/vendor/webrat/lib/webrat/core/elements/link.rb +0 -90
- data/vendor/webrat/lib/webrat/core/elements/select_option.rb +0 -35
- data/vendor/webrat/lib/webrat/core/locators.rb +0 -20
- data/vendor/webrat/lib/webrat/core/locators/area_locator.rb +0 -38
- data/vendor/webrat/lib/webrat/core/locators/button_locator.rb +0 -54
- data/vendor/webrat/lib/webrat/core/locators/field_by_id_locator.rb +0 -37
- data/vendor/webrat/lib/webrat/core/locators/field_labeled_locator.rb +0 -56
- data/vendor/webrat/lib/webrat/core/locators/field_locator.rb +0 -25
- data/vendor/webrat/lib/webrat/core/locators/field_named_locator.rb +0 -41
- data/vendor/webrat/lib/webrat/core/locators/form_locator.rb +0 -19
- data/vendor/webrat/lib/webrat/core/locators/label_locator.rb +0 -34
- data/vendor/webrat/lib/webrat/core/locators/link_locator.rb +0 -66
- data/vendor/webrat/lib/webrat/core/locators/locator.rb +0 -20
- data/vendor/webrat/lib/webrat/core/locators/select_option_locator.rb +0 -59
- data/vendor/webrat/lib/webrat/core/logging.rb +0 -21
- data/vendor/webrat/lib/webrat/core/matchers.rb +0 -4
- data/vendor/webrat/lib/webrat/core/matchers/have_content.rb +0 -73
- data/vendor/webrat/lib/webrat/core/matchers/have_selector.rb +0 -74
- data/vendor/webrat/lib/webrat/core/matchers/have_tag.rb +0 -21
- data/vendor/webrat/lib/webrat/core/matchers/have_xpath.rb +0 -147
- data/vendor/webrat/lib/webrat/core/methods.rb +0 -61
- data/vendor/webrat/lib/webrat/core/mime.rb +0 -29
- data/vendor/webrat/lib/webrat/core/save_and_open_page.rb +0 -50
- data/vendor/webrat/lib/webrat/core/scope.rb +0 -350
- data/vendor/webrat/lib/webrat/core/session.rb +0 -281
- data/vendor/webrat/lib/webrat/core/xml.rb +0 -115
- data/vendor/webrat/lib/webrat/core/xml/hpricot.rb +0 -19
- data/vendor/webrat/lib/webrat/core/xml/nokogiri.rb +0 -76
- data/vendor/webrat/lib/webrat/core/xml/rexml.rb +0 -24
- data/vendor/webrat/lib/webrat/core_extensions/blank.rb +0 -58
- data/vendor/webrat/lib/webrat/core_extensions/deprecate.rb +0 -8
- data/vendor/webrat/lib/webrat/core_extensions/detect_mapped.rb +0 -12
- data/vendor/webrat/lib/webrat/core_extensions/meta_class.rb +0 -6
- data/vendor/webrat/lib/webrat/core_extensions/nil_to_param.rb +0 -5
- data/vendor/webrat/lib/webrat/mechanize.rb +0 -74
- data/vendor/webrat/lib/webrat/merb.rb +0 -9
- data/vendor/webrat/lib/webrat/merb_session.rb +0 -65
- data/vendor/webrat/lib/webrat/rack.rb +0 -24
- data/vendor/webrat/lib/webrat/rails.rb +0 -105
- data/vendor/webrat/lib/webrat/rspec-rails.rb +0 -13
- data/vendor/webrat/lib/webrat/selenium.rb +0 -154
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/button.js +0 -12
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/label.js +0 -16
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webrat.js +0 -5
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlink.js +0 -9
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js +0 -15
- data/vendor/webrat/lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js +0 -5
- data/vendor/webrat/lib/webrat/selenium/matchers.rb +0 -4
- data/vendor/webrat/lib/webrat/selenium/matchers/have_content.rb +0 -66
- data/vendor/webrat/lib/webrat/selenium/matchers/have_selector.rb +0 -49
- data/vendor/webrat/lib/webrat/selenium/matchers/have_tag.rb +0 -72
- data/vendor/webrat/lib/webrat/selenium/matchers/have_xpath.rb +0 -45
- data/vendor/webrat/lib/webrat/selenium/selenium_extensions.js +0 -6
- data/vendor/webrat/lib/webrat/selenium/selenium_session.rb +0 -247
- data/vendor/webrat/lib/webrat/sinatra.rb +0 -44
- data/vendor/webrat/spec/fakes/test_session.rb +0 -34
- data/vendor/webrat/spec/integration/merb/Rakefile +0 -35
- data/vendor/webrat/spec/integration/merb/app/controllers/application.rb +0 -2
- data/vendor/webrat/spec/integration/merb/app/controllers/exceptions.rb +0 -13
- data/vendor/webrat/spec/integration/merb/app/controllers/testing.rb +0 -18
- data/vendor/webrat/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +0 -63
- data/vendor/webrat/spec/integration/merb/app/views/exceptions/not_found.html.erb +0 -47
- data/vendor/webrat/spec/integration/merb/app/views/layout/application.html.erb +0 -12
- data/vendor/webrat/spec/integration/merb/app/views/testing/show_form.html.erb +0 -27
- data/vendor/webrat/spec/integration/merb/config/environments/development.rb +0 -15
- data/vendor/webrat/spec/integration/merb/config/environments/rake.rb +0 -11
- data/vendor/webrat/spec/integration/merb/config/environments/test.rb +0 -14
- data/vendor/webrat/spec/integration/merb/config/init.rb +0 -25
- data/vendor/webrat/spec/integration/merb/config/rack.rb +0 -11
- data/vendor/webrat/spec/integration/merb/config/router.rb +0 -33
- data/vendor/webrat/spec/integration/merb/spec/spec.opts +0 -1
- data/vendor/webrat/spec/integration/merb/spec/spec_helper.rb +0 -24
- data/vendor/webrat/spec/integration/merb/spec/webrat_spec.rb +0 -32
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/app_script.rb +0 -31
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/common.rb +0 -64
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/gem_ext.rb +0 -124
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/main.thor +0 -150
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/ops.rb +0 -93
- data/vendor/webrat/spec/integration/merb/tasks/merb.thor/utils.rb +0 -40
- data/vendor/webrat/spec/integration/rails/Rakefile +0 -30
- data/vendor/webrat/spec/integration/rails/app/controllers/application.rb +0 -15
- data/vendor/webrat/spec/integration/rails/app/controllers/webrat_controller.rb +0 -39
- data/vendor/webrat/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +0 -4
- data/vendor/webrat/spec/integration/rails/app/views/webrat/form.html.erb +0 -28
- data/vendor/webrat/spec/integration/rails/config/boot.rb +0 -109
- data/vendor/webrat/spec/integration/rails/config/environment.rb +0 -12
- data/vendor/webrat/spec/integration/rails/config/environments/development.rb +0 -17
- data/vendor/webrat/spec/integration/rails/config/environments/selenium.rb +0 -22
- data/vendor/webrat/spec/integration/rails/config/environments/test.rb +0 -22
- data/vendor/webrat/spec/integration/rails/config/initializers/inflections.rb +0 -10
- data/vendor/webrat/spec/integration/rails/config/initializers/mime_types.rb +0 -5
- data/vendor/webrat/spec/integration/rails/config/initializers/new_rails_defaults.rb +0 -17
- data/vendor/webrat/spec/integration/rails/config/locales/en.yml +0 -5
- data/vendor/webrat/spec/integration/rails/config/routes.rb +0 -14
- data/vendor/webrat/spec/integration/rails/public/404.html +0 -30
- data/vendor/webrat/spec/integration/rails/public/422.html +0 -30
- data/vendor/webrat/spec/integration/rails/public/500.html +0 -33
- data/vendor/webrat/spec/integration/rails/script/about +0 -4
- data/vendor/webrat/spec/integration/rails/script/console +0 -3
- data/vendor/webrat/spec/integration/rails/script/dbconsole +0 -3
- data/vendor/webrat/spec/integration/rails/script/destroy +0 -3
- data/vendor/webrat/spec/integration/rails/script/generate +0 -3
- data/vendor/webrat/spec/integration/rails/script/performance/benchmarker +0 -3
- data/vendor/webrat/spec/integration/rails/script/performance/profiler +0 -3
- data/vendor/webrat/spec/integration/rails/script/performance/request +0 -3
- data/vendor/webrat/spec/integration/rails/script/plugin +0 -3
- data/vendor/webrat/spec/integration/rails/script/process/inspector +0 -3
- data/vendor/webrat/spec/integration/rails/script/process/reaper +0 -3
- data/vendor/webrat/spec/integration/rails/script/process/spawner +0 -3
- data/vendor/webrat/spec/integration/rails/script/runner +0 -3
- data/vendor/webrat/spec/integration/rails/script/server +0 -3
- data/vendor/webrat/spec/integration/rails/test/integration/webrat_test.rb +0 -80
- data/vendor/webrat/spec/integration/rails/test/test_helper.rb +0 -25
- data/vendor/webrat/spec/integration/sinatra/Rakefile +0 -5
- data/vendor/webrat/spec/integration/sinatra/classic_app.rb +0 -64
- data/vendor/webrat/spec/integration/sinatra/modular_app.rb +0 -16
- data/vendor/webrat/spec/integration/sinatra/test/classic_app_test.rb +0 -37
- data/vendor/webrat/spec/integration/sinatra/test/modular_app_test.rb +0 -18
- data/vendor/webrat/spec/integration/sinatra/test/test_helper.rb +0 -16
- data/vendor/webrat/spec/private/core/configuration_spec.rb +0 -104
- data/vendor/webrat/spec/private/core/field_spec.rb +0 -67
- data/vendor/webrat/spec/private/core/link_spec.rb +0 -24
- data/vendor/webrat/spec/private/core/logging_spec.rb +0 -10
- data/vendor/webrat/spec/private/core/session_spec.rb +0 -198
- data/vendor/webrat/spec/private/mechanize/mechanize_session_spec.rb +0 -81
- data/vendor/webrat/spec/private/merb/merb_session_spec.rb +0 -42
- data/vendor/webrat/spec/private/nokogiri_spec.rb +0 -77
- data/vendor/webrat/spec/private/rails/attaches_file_spec.rb +0 -81
- data/vendor/webrat/spec/private/rails/rails_session_spec.rb +0 -110
- data/vendor/webrat/spec/private/selenium/selenium_session_spec.rb +0 -44
- data/vendor/webrat/spec/private/selenium/selenium_spec.rb +0 -109
- data/vendor/webrat/spec/public/basic_auth_spec.rb +0 -24
- data/vendor/webrat/spec/public/check_spec.rb +0 -191
- data/vendor/webrat/spec/public/choose_spec.rb +0 -118
- data/vendor/webrat/spec/public/click_area_spec.rb +0 -106
- data/vendor/webrat/spec/public/click_button_spec.rb +0 -502
- data/vendor/webrat/spec/public/click_link_spec.rb +0 -469
- data/vendor/webrat/spec/public/fill_in_spec.rb +0 -209
- data/vendor/webrat/spec/public/locators/field_by_xpath_spec.rb +0 -19
- data/vendor/webrat/spec/public/locators/field_labeled_spec.rb +0 -157
- data/vendor/webrat/spec/public/locators/field_with_id_spec.rb +0 -16
- data/vendor/webrat/spec/public/matchers/contain_spec.rb +0 -114
- data/vendor/webrat/spec/public/matchers/have_selector_spec.rb +0 -135
- data/vendor/webrat/spec/public/matchers/have_tag_spec.rb +0 -39
- data/vendor/webrat/spec/public/matchers/have_xpath_spec.rb +0 -123
- data/vendor/webrat/spec/public/reload_spec.rb +0 -10
- data/vendor/webrat/spec/public/save_and_open_spec.rb +0 -51
- data/vendor/webrat/spec/public/select_date_spec.rb +0 -88
- data/vendor/webrat/spec/public/select_datetime_spec.rb +0 -106
- data/vendor/webrat/spec/public/select_spec.rb +0 -246
- data/vendor/webrat/spec/public/select_time_spec.rb +0 -79
- data/vendor/webrat/spec/public/set_hidden_field_spec.rb +0 -5
- data/vendor/webrat/spec/public/submit_form_spec.rb +0 -5
- data/vendor/webrat/spec/public/visit_spec.rb +0 -58
- data/vendor/webrat/spec/public/within_spec.rb +0 -177
- data/vendor/webrat/spec/rcov.opts +0 -1
- data/vendor/webrat/spec/spec.opts +0 -2
- data/vendor/webrat/spec/spec_helper.rb +0 -50
- data/vendor/webrat/vendor/selenium-server.jar +0 -0
@@ -0,0 +1,108 @@
|
|
1
|
+
require "dm-sweatshop"
|
2
|
+
|
3
|
+
include DataMapper::Sweatshop::Unique
|
4
|
+
|
5
|
+
class Array
|
6
|
+
def pick
|
7
|
+
self[rand(self.length)]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_notifier!(name)
|
12
|
+
klass = Class.new(Integrity::Notifier::Base) do
|
13
|
+
def self.to_haml; ""; end
|
14
|
+
def deliver!; nil; end
|
15
|
+
end
|
16
|
+
|
17
|
+
unless Integrity::Notifier.const_defined?(name)
|
18
|
+
Integrity::Notifier.const_set(name, klass)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Integrity::Project.fixture do
|
23
|
+
{ :name => (name = unique { /\w+/.gen }),
|
24
|
+
:uri => "git://github.com/#{/\w+/.gen}/#{name}.git",
|
25
|
+
:branch => ["master", "test-refactoring", "lh-34"].pick,
|
26
|
+
:command => ["rake", "make", "ant -buildfile test.xml"].pick,
|
27
|
+
:public => [true, false].pick,
|
28
|
+
:building => [true, false].pick }
|
29
|
+
end
|
30
|
+
|
31
|
+
Integrity::Project.fixture(:integrity) do
|
32
|
+
{ :name => "Integrity",
|
33
|
+
:uri => "git://github.com/foca/integrity.git",
|
34
|
+
:branch => "master",
|
35
|
+
:command => "rake",
|
36
|
+
:public => true,
|
37
|
+
:building => false }
|
38
|
+
end
|
39
|
+
|
40
|
+
Integrity::Project.fixture(:my_test_project) do
|
41
|
+
{ :name => "My Test Project",
|
42
|
+
:uri => File.dirname(__FILE__) + "/../../",
|
43
|
+
:branch => "master",
|
44
|
+
:command => "./test",
|
45
|
+
:public => true,
|
46
|
+
:building => false }
|
47
|
+
end
|
48
|
+
|
49
|
+
Integrity::Commit.fixture do
|
50
|
+
project = Integrity::Project.first || Integrity::Project.gen
|
51
|
+
|
52
|
+
{ :identifier => Digest::SHA1.hexdigest(/[:paragraph:]/.gen),
|
53
|
+
:message => /[:sentence:]/.gen,
|
54
|
+
:author => /\w+ \w+ <\w+@example.org>/.gen,
|
55
|
+
:committed_at => unique {|i| Time.mktime(2008, 12, 15, 18, (59 - i) % 60) },
|
56
|
+
:project_id => project.id }
|
57
|
+
end
|
58
|
+
|
59
|
+
Integrity::Commit.fixture(:successful) do
|
60
|
+
Integrity::Commit.generate_attributes.update(:build => Integrity::Build.gen(:successful))
|
61
|
+
end
|
62
|
+
|
63
|
+
Integrity::Commit.fixture(:failed) do
|
64
|
+
Integrity::Commit.generate_attributes.update(:build => Integrity::Build.gen(:failed))
|
65
|
+
end
|
66
|
+
|
67
|
+
Integrity::Commit.fixture(:pending) do
|
68
|
+
Integrity::Commit.generate_attributes.update(:build => Integrity::Build.gen(:pending))
|
69
|
+
end
|
70
|
+
|
71
|
+
Integrity::Build.fixture do
|
72
|
+
commit = Integrity::Commit.first || Integrity::Commit.gen
|
73
|
+
|
74
|
+
{ :output => /[:paragraph:]/.gen,
|
75
|
+
:successful => true,
|
76
|
+
:started_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
|
77
|
+
:created_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
|
78
|
+
:completed_at => unique {|i| Time.mktime(2008, 12, 15, 18, i % 60) },
|
79
|
+
:commit_id => commit.id }
|
80
|
+
end
|
81
|
+
|
82
|
+
Integrity::Build.fixture(:successful) do
|
83
|
+
Integrity::Build.generate_attributes.update(:successful => true)
|
84
|
+
end
|
85
|
+
|
86
|
+
Integrity::Build.fixture(:failed) do
|
87
|
+
Integrity::Build.generate_attributes.update(:successful => false)
|
88
|
+
end
|
89
|
+
|
90
|
+
Integrity::Build.fixture(:pending) do
|
91
|
+
Integrity::Build.generate_attributes.update(:successful => nil, :started_at => nil, :completed_at => nil)
|
92
|
+
end
|
93
|
+
|
94
|
+
Integrity::Notifier.fixture(:irc) do
|
95
|
+
create_notifier! "IRC"
|
96
|
+
|
97
|
+
{ :project => Integrity::Project.generate,
|
98
|
+
:name => "IRC",
|
99
|
+
:config => { :uri => "irc://irc.freenode.net/integrity" }}
|
100
|
+
end
|
101
|
+
|
102
|
+
Integrity::Notifier.fixture(:twitter) do
|
103
|
+
create_notifier! "Twitter"
|
104
|
+
|
105
|
+
{ :project => Integrity::Project.generate,
|
106
|
+
:name => "Twitter",
|
107
|
+
:config => { :email => "foo@example.org", :pass => "secret" }}
|
108
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "hpricot"
|
2
|
+
|
3
|
+
module Integrity
|
4
|
+
class Notifier
|
5
|
+
module Test
|
6
|
+
# Thanks Harry! http://gist.github.com/39960
|
7
|
+
class HpricotMatcher
|
8
|
+
def initialize(html)
|
9
|
+
@doc = Hpricot(html)
|
10
|
+
end
|
11
|
+
|
12
|
+
# elements('h1') returns a Hpricot::Elements object with all h1-tags.
|
13
|
+
def elements(selector)
|
14
|
+
@doc.search(selector)
|
15
|
+
end
|
16
|
+
|
17
|
+
# element('h1') returns Hpricot::Elem with first h1-tag, or nil if
|
18
|
+
# none exist.
|
19
|
+
def element(selector)
|
20
|
+
@doc.at(selector)
|
21
|
+
end
|
22
|
+
|
23
|
+
# tags('h1') returns the inner HTML of all matched elements mathed.
|
24
|
+
def tags(selector)
|
25
|
+
e = elements(selector)
|
26
|
+
e.map {|x| x.inner_html}
|
27
|
+
end
|
28
|
+
|
29
|
+
# tag('h1') returns the inner HTML of the first mached element, or
|
30
|
+
# nil if none matched.
|
31
|
+
def tag(selector)
|
32
|
+
e = element(selector)
|
33
|
+
e && e.inner_html
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/helpers"
|
2
|
-
require
|
2
|
+
require "helpers/acceptance/textfile_notifier"
|
3
3
|
|
4
4
|
class BuildNotificationsTest < Test::Unit::AcceptanceTestCase
|
5
5
|
story <<-EOS
|
@@ -11,7 +11,7 @@ class BuildNotificationsTest < Test::Unit::AcceptanceTestCase
|
|
11
11
|
before(:each) do
|
12
12
|
# This is needed before any available notifier is unset
|
13
13
|
# in the global #before
|
14
|
-
load
|
14
|
+
load "helpers/acceptance/textfile_notifier.rb"
|
15
15
|
end
|
16
16
|
|
17
17
|
scenario "an admin sets up a notifier for a project that didn't have any" do
|
@@ -18,11 +18,9 @@ class InstallerTest < Test::Unit::AcceptanceTestCase
|
|
18
18
|
Pathname("/tmp/i-haz-integrity")
|
19
19
|
end
|
20
20
|
|
21
|
-
def install(
|
22
|
-
installer =
|
23
|
-
installer
|
24
|
-
stdout, _ = util_capture { installer.install(root.to_s) }
|
25
|
-
stdout
|
21
|
+
def install(option="")
|
22
|
+
installer = File.dirname(__FILE__) + "/../../bin/integrity"
|
23
|
+
IO.popen("#{installer} install #{root} #{option}".strip).read
|
26
24
|
end
|
27
25
|
|
28
26
|
scenario "Installing integrity into a given directory" do
|
@@ -33,6 +31,10 @@ class InstallerTest < Test::Unit::AcceptanceTestCase
|
|
33
31
|
assert ! root.join("public").directory?
|
34
32
|
assert ! root.join("tmp").directory?
|
35
33
|
|
34
|
+
assert ! root.join("Rakefile").file?
|
35
|
+
assert ! root.join("integrity.rb").file?
|
36
|
+
assert ! root.join(".gems").file?
|
37
|
+
|
36
38
|
assert ! root.join("thin.yml").file?
|
37
39
|
assert root.join("config.ru").file?
|
38
40
|
|
@@ -44,14 +46,14 @@ class InstallerTest < Test::Unit::AcceptanceTestCase
|
|
44
46
|
end
|
45
47
|
|
46
48
|
scenario "Installing integrity for Passenger" do
|
47
|
-
install(
|
49
|
+
install("--passenger")
|
48
50
|
|
49
51
|
assert root.join("public").directory?
|
50
52
|
assert root.join("tmp").directory?
|
51
53
|
end
|
52
54
|
|
53
55
|
scenario "Installing Integrity for Thin" do
|
54
|
-
install(
|
56
|
+
install("--thin")
|
55
57
|
|
56
58
|
config = YAML.load_file(root.join("thin.yml"))
|
57
59
|
config["chdir"].should == root.to_s
|
@@ -59,4 +61,20 @@ class InstallerTest < Test::Unit::AcceptanceTestCase
|
|
59
61
|
config["rackup"].should == root.join("config.ru").to_s
|
60
62
|
config["log"].should == root.join("log/thin.log").to_s
|
61
63
|
end
|
64
|
+
|
65
|
+
scenario "Installing Integrity for Heroku" do
|
66
|
+
message = install("--heroku")
|
67
|
+
|
68
|
+
gemifest = root.join(".gems").read
|
69
|
+
assert gemifest.include?("mailfactory")
|
70
|
+
assert gemifest.include?("tlsmail")
|
71
|
+
assert gemifest.include?("foca-sinatra-ditties")
|
72
|
+
assert gemifest.include?("integrity")
|
73
|
+
|
74
|
+
assert root.join("Rakefile").file?
|
75
|
+
assert root.join("integrity-config.rb").file?
|
76
|
+
assert root.join("config.ru").file?
|
77
|
+
|
78
|
+
assert message.include?("ready to be deployed onto Heroku")
|
79
|
+
end
|
62
80
|
end
|
data/test/helpers.rb
CHANGED
data/test/helpers/acceptance.rb
CHANGED
@@ -61,12 +61,9 @@ class Test::Unit::AcceptanceTestCase < Test::Unit::TestCase
|
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
64
|
-
before(:all) do
|
65
|
-
Integrity.config[:base_uri] = "http://www.example.com"
|
66
|
-
end
|
67
|
-
|
68
64
|
before(:each) do
|
69
65
|
# ensure each scenario is run in a clean sandbox
|
66
|
+
Integrity.config[:base_uri] = "http://www.example.com"
|
70
67
|
enable_auth!
|
71
68
|
setup_log!
|
72
69
|
set_and_create_export_directory!
|
data/test/helpers/fixtures.rb
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
require "dm-sweatshop"
|
2
|
-
|
3
|
-
include DataMapper::Sweatshop::Unique
|
4
|
-
|
5
|
-
class Array
|
6
|
-
def pick
|
7
|
-
self[rand(self.length)]
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def create_notifier!(name)
|
12
|
-
klass = Class.new(Integrity::Notifier::Base) do
|
13
|
-
def self.to_haml; ""; end
|
14
|
-
def deliver!; nil; end
|
15
|
-
end
|
16
|
-
|
17
|
-
unless Integrity::Notifier.const_defined?(name)
|
18
|
-
Integrity::Notifier.const_set(name, klass)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
1
|
Integrity::Project.fixture do
|
24
2
|
{ :name => (name = unique { /\w+/.gen }),
|
25
3
|
:uri => "git://github.com/#{/\w+/.gen}/#{name}.git",
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../../helpers"
|
2
|
+
require "helpers/acceptance/textfile_notifier"
|
3
|
+
|
4
|
+
require "integrity/notifier/test"
|
5
|
+
|
6
|
+
class NotifierTestTest < Test::Unit::TestCase
|
7
|
+
include Integrity::Notifier::Test
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
# Because we unset every notifier in global setup
|
11
|
+
load "helpers/acceptance/textfile_notifier.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def notifier
|
15
|
+
"Textfile"
|
16
|
+
end
|
17
|
+
|
18
|
+
test "it provides a formulary to configure options" do
|
19
|
+
assert_form_have_option("file")
|
20
|
+
end
|
21
|
+
|
22
|
+
test "it sends notification" do
|
23
|
+
commit = Integrity::Commit.gen(:build => Build.gen(:successful))
|
24
|
+
|
25
|
+
assert notification(commit).include?(commit.identifier)
|
26
|
+
assert notification_failed.include?("failed")
|
27
|
+
assert notification_successful.include?("was successful")
|
28
|
+
end
|
29
|
+
end
|
@@ -2,7 +2,10 @@ require File.dirname(__FILE__) + "/../helpers"
|
|
2
2
|
|
3
3
|
class ProjectBuilderTest < Test::Unit::TestCase
|
4
4
|
before(:all) do
|
5
|
-
Integrity.config[:export_directory]
|
5
|
+
unless File.directory?(Integrity.config[:export_directory])
|
6
|
+
FileUtils.mkdir(Integrity.config[:export_directory])
|
7
|
+
end
|
8
|
+
|
6
9
|
@directory = Integrity.config[:export_directory] + "/foca-integrity-master"
|
7
10
|
FileUtils.mkdir(@directory)
|
8
11
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
|
3
|
+
module Sinatra
|
4
|
+
module Ditties
|
5
|
+
def self.version
|
6
|
+
"0.0.2".freeze
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
autoload :Authorization, File.dirname(__FILE__) + "/ditties/authorization"
|
11
|
+
autoload :Mailer, File.dirname(__FILE__) + "/ditties/mailer"
|
12
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Sinatra
|
2
|
+
# HTTP Authorization helpers for Sinatra.
|
3
|
+
#
|
4
|
+
# In your helpers module, include Sinatra::Authorization and then define
|
5
|
+
# a +authorize(user, password)+ method to handle user provided
|
6
|
+
# credentials.
|
7
|
+
#
|
8
|
+
# Inside your events, call +login_required+ to trigger the HTTP
|
9
|
+
# Authorization window to pop up in the browser.
|
10
|
+
#
|
11
|
+
# Code adapted from Ryan Tomayko <http://tomayko.com> and Christopher
|
12
|
+
# Schneid <http://gittr.com>, shared under an MIT License
|
13
|
+
module Authorization
|
14
|
+
# Redefine this method on your helpers block to actually contain
|
15
|
+
# your authorization logic.
|
16
|
+
def authorize(username, password)
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
# From you app, call set :authorization_realm, "my app" to set this
|
21
|
+
# or define a `authorization_realm` method in your helpers block.
|
22
|
+
def authorization_realm
|
23
|
+
Sinatra::Default.authorization_realm
|
24
|
+
end
|
25
|
+
|
26
|
+
# Call in any event that requires authentication
|
27
|
+
def login_required
|
28
|
+
return if authorized?
|
29
|
+
unauthorized! unless auth.provided?
|
30
|
+
bad_request! unless auth.basic?
|
31
|
+
unauthorized! unless authorize(*auth.credentials)
|
32
|
+
request.env['REMOTE_USER'] = auth.username
|
33
|
+
end
|
34
|
+
|
35
|
+
# Convenience method to determine if a user is logged in
|
36
|
+
def authorized?
|
37
|
+
!!request.env['REMOTE_USER']
|
38
|
+
end
|
39
|
+
alias :logged_in? :authorized?
|
40
|
+
|
41
|
+
# Name provided by the current user to log in
|
42
|
+
def current_user
|
43
|
+
request.env['REMOTE_USER']
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def auth
|
49
|
+
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
50
|
+
end
|
51
|
+
|
52
|
+
def unauthorized!(realm=authorization_realm)
|
53
|
+
response["WWW-Authenticate"] = %(Basic realm="#{realm}")
|
54
|
+
throw :halt, [ 401, 'Authorization Required' ]
|
55
|
+
end
|
56
|
+
|
57
|
+
def bad_request!
|
58
|
+
throw :halt, [ 400, 'Bad Request' ]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# Shamelssly stolen from Merb::Mailer
|
2
|
+
# http://merbivore.com
|
3
|
+
|
4
|
+
require 'net/smtp'
|
5
|
+
require 'rubygems'
|
6
|
+
require 'mailfactory'
|
7
|
+
require 'tlsmail'
|
8
|
+
|
9
|
+
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
|
10
|
+
|
11
|
+
class MailFactory
|
12
|
+
attr_reader :html, :text
|
13
|
+
end
|
14
|
+
|
15
|
+
module Sinatra
|
16
|
+
# = Sinatra::Mailer
|
17
|
+
#
|
18
|
+
# Adds an #email method to your email handlers, that receives a hash of
|
19
|
+
# values to create your email.
|
20
|
+
#
|
21
|
+
# For example:
|
22
|
+
#
|
23
|
+
# post "/signup" do
|
24
|
+
# # sign up the user, and then:
|
25
|
+
# email :to => @user.email,
|
26
|
+
# :from => "awesomeness@example.com",
|
27
|
+
# :subject => "Welcome to Awesomeness!",
|
28
|
+
# :body => haml(:some_template)
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# == Configuration
|
32
|
+
#
|
33
|
+
# This plugin is very dirty yet :) Since it's just a port to Sinatra of
|
34
|
+
# Merb::Mailer[merbivore.com/documentation/1.0/doc/rdoc/merb-mailer-1.0].
|
35
|
+
# So the configuration is not Sinatra-y, yet. But we'll get to that.
|
36
|
+
#
|
37
|
+
# == Using SMTP
|
38
|
+
#
|
39
|
+
# Sinatra::Mailer.config = {
|
40
|
+
# :host => 'smtp.yourserver.com',
|
41
|
+
# :port => '25',
|
42
|
+
# :user => 'user',
|
43
|
+
# :pass => 'pass',
|
44
|
+
# :auth => :plain # :plain, :login, :cram_md5, the default is no auth
|
45
|
+
# :domain => "localhost.localdomain" # HELO domain provided by the client
|
46
|
+
# }
|
47
|
+
#
|
48
|
+
# == Using Gmail SMTP
|
49
|
+
#
|
50
|
+
# You need smtp-tls[http://github.com/ambethia/smtp-tls], a gem that improves
|
51
|
+
# Net::HTTP to add support for secure servers such as Gmail.
|
52
|
+
#
|
53
|
+
# require "smtp-tls"
|
54
|
+
#
|
55
|
+
# Sinatra::Mailer.config = {
|
56
|
+
# :host => 'smtp.gmail.com',
|
57
|
+
# :port => '587',
|
58
|
+
# :user => 'user@gmail.com',
|
59
|
+
# :pass => 'pass',
|
60
|
+
# :auth => :plain
|
61
|
+
# }
|
62
|
+
#
|
63
|
+
# Make sure that when you call your #email method you pass the
|
64
|
+
# +:text+ option and not +:body+.
|
65
|
+
#
|
66
|
+
# == Using sendmail
|
67
|
+
#
|
68
|
+
# Sinatra::Mailer.config = {:sendmail_path => '/somewhere/odd'}
|
69
|
+
# Sinatra::Mailer.delivery_method = :sendmail
|
70
|
+
#
|
71
|
+
# == Credits
|
72
|
+
#
|
73
|
+
# This has been blatantly adapted from
|
74
|
+
# Merb::Mailer[merbivore.com/documentation/1.0/doc/rdoc/merb-mailer-1.0]
|
75
|
+
# so all credit is theirs, I just ported it to Sinatra.
|
76
|
+
module Mailer
|
77
|
+
class << self
|
78
|
+
attr_accessor :config, :delivery_method
|
79
|
+
end
|
80
|
+
|
81
|
+
def email(mail_options={})
|
82
|
+
Email.new(mail_options).deliver!
|
83
|
+
end
|
84
|
+
|
85
|
+
class Email
|
86
|
+
attr_accessor :mail, :config
|
87
|
+
|
88
|
+
# Sends the mail using sendmail.
|
89
|
+
def sendmail
|
90
|
+
sendmail = IO.popen("#{config[:sendmail_path]} #{@mail.to}", 'w+')
|
91
|
+
sendmail.puts @mail.to_s
|
92
|
+
sendmail.close
|
93
|
+
end
|
94
|
+
|
95
|
+
# Sends the mail using SMTP.
|
96
|
+
def net_smtp
|
97
|
+
Net::SMTP.start(config[:host], config[:port].to_i, config[:domain],
|
98
|
+
config[:user], config[:pass], config[:auth]) { |smtp|
|
99
|
+
smtp.send_message(@mail.to_s, @mail.from.first, @mail.to.to_s.split(/[,;]/))
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
# Delivers the mail with the specified delivery method, defaulting to
|
104
|
+
# net_smtp.
|
105
|
+
def deliver!
|
106
|
+
send(Mailer.delivery_method || :net_smtp)
|
107
|
+
end
|
108
|
+
|
109
|
+
# ==== Parameters
|
110
|
+
# file_or_files<File, Array[File]>:: File(s) to attach.
|
111
|
+
# filename<String>::
|
112
|
+
# type<~to_s>::
|
113
|
+
# The attachment MIME type. If left out, it will be determined from
|
114
|
+
# file_or_files.
|
115
|
+
# headers<String, Array>:: Additional attachment headers.
|
116
|
+
#
|
117
|
+
# ==== Raises
|
118
|
+
# ArgumentError::
|
119
|
+
# file_or_files was not a File or an Array of File instances.
|
120
|
+
def attach(file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,
|
121
|
+
type = nil, headers = nil)
|
122
|
+
if file_or_files.is_a?(Array)
|
123
|
+
file_or_files.each {|k,v| @mail.add_attachment_as k, *v}
|
124
|
+
else
|
125
|
+
raise ArgumentError, "You did not pass in a file. Instead, you sent a #{file_or_files.class}" if !file_or_files.is_a?(File)
|
126
|
+
@mail.add_attachment_as(file_or_files, filename, type, headers)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# ==== Parameters
|
131
|
+
# o<Hash{~to_s => Object}>:: Configuration commands to send to MailFactory.
|
132
|
+
def initialize(o={})
|
133
|
+
self.config = Mailer.config || {:sendmail_path => '/usr/sbin/sendmail'}
|
134
|
+
o[:rawhtml] = o.delete(:html)
|
135
|
+
m = MailFactory.new()
|
136
|
+
o.each { |k,v| m.send "#{k}=", v }
|
137
|
+
@mail = m
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
class EventContext
|
144
|
+
include Mailer
|
145
|
+
end
|
146
|
+
end
|