integrity 0.1.9.1 → 0.1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/CHANGES +28 -0
- data/README.markdown +6 -0
- data/Rakefile +44 -83
- data/config/heroku/.gems +0 -3
- data/config/heroku/integrity-config.rb +4 -1
- data/integrity.gemspec +18 -6
- data/lib/integrity.rb +9 -5
- data/lib/integrity/app.rb +8 -8
- data/lib/integrity/build.rb +7 -7
- data/lib/integrity/helpers/authorization.rb +1 -1
- data/lib/integrity/helpers/breadcrumbs.rb +1 -1
- data/lib/integrity/helpers/rendering.rb +8 -2
- data/lib/integrity/helpers/urls.rb +33 -23
- data/lib/integrity/installer.rb +18 -17
- data/lib/integrity/notifier/base.rb +7 -2
- data/lib/integrity/project.rb +2 -2
- data/test/acceptance/api_test.rb +1 -1
- data/test/acceptance/browse_project_builds_test.rb +1 -1
- data/test/acceptance/browse_project_test.rb +1 -1
- data/test/acceptance/build_notifications_test.rb +1 -1
- data/test/acceptance/create_project_test.rb +1 -1
- data/test/acceptance/delete_project_test.rb +1 -1
- data/test/acceptance/edit_project_test.rb +1 -1
- data/test/acceptance/error_page_test.rb +1 -1
- data/test/acceptance/installer_test.rb +2 -6
- data/test/acceptance/manual_build_project_test.rb +1 -1
- data/test/acceptance/not_found_page_test.rb +29 -0
- data/test/acceptance/notifier_test.rb +1 -1
- data/test/acceptance/project_syndication_test.rb +1 -1
- data/test/acceptance/stylesheet_test.rb +10 -2
- data/test/acceptance/unauthorized_page_test.rb +20 -0
- data/test/helpers.rb +13 -7
- data/test/helpers/acceptance.rb +1 -0
- data/test/unit/build_test.rb +10 -0
- data/test/unit/helpers_test.rb +63 -20
- data/test/unit/integrity_test.rb +23 -6
- data/test/unit/notifier_test.rb +5 -0
- data/test/unit/project_test.rb +5 -0
- data/views/home.haml +2 -2
- data/views/layout.haml +6 -5
- data/views/new.haml +1 -1
- data/views/not_found.haml +2 -2
- data/views/unauthorized.haml +4 -4
- metadata +105 -6
- data/test/acceptance/helpers.rb +0 -2
- data/vendor/sinatra-ditties/README.rdoc +0 -3
- data/vendor/sinatra-ditties/lib/sinatra/ditties.rb +0 -12
- data/vendor/sinatra-ditties/lib/sinatra/ditties/authorization.rb +0 -61
- data/vendor/sinatra-ditties/lib/sinatra/ditties/mailer.rb +0 -146
@@ -1,9 +1,15 @@
|
|
1
1
|
module Integrity
|
2
2
|
module Helpers
|
3
3
|
module Rendering
|
4
|
+
def stylesheets(*sheets)
|
5
|
+
sheets.each { |sheet|
|
6
|
+
haml_tag(:link, :href => root_path("/#{sheet}.css"),
|
7
|
+
:type => "text/css", :rel => "stylesheet")
|
8
|
+
}
|
9
|
+
end
|
10
|
+
|
4
11
|
def stylesheet_hash
|
5
|
-
@_hash ||= Digest::MD5.file(
|
6
|
-
options.views + "/integrity.sass").tap { |file| file.hexdigest }
|
12
|
+
@_hash ||= Digest::MD5.file(options.views + "/integrity.sass").hexdigest
|
7
13
|
end
|
8
14
|
|
9
15
|
def show(view, options={})
|
@@ -1,49 +1,59 @@
|
|
1
1
|
module Integrity
|
2
2
|
module Helpers
|
3
3
|
module Urls
|
4
|
-
def url(path)
|
5
|
-
Addressable::URI.parse(request.url).join(path).to_s
|
6
|
-
end
|
7
|
-
|
8
4
|
def root_url
|
9
|
-
url(
|
5
|
+
@url ||= Addressable::URI.parse(base_url)
|
10
6
|
end
|
11
7
|
|
12
|
-
def
|
13
|
-
|
8
|
+
def root_path(path="")
|
9
|
+
url(path).path
|
14
10
|
end
|
15
11
|
|
16
12
|
def project_url(project, *path)
|
17
|
-
url
|
13
|
+
url("/" << [project.permalink, *path].flatten.join("/"))
|
18
14
|
end
|
19
15
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
end.to_s
|
16
|
+
def project_path(project, *path)
|
17
|
+
project_url(project, path).path
|
18
|
+
end
|
19
|
+
|
20
|
+
def commit_url(commit)
|
21
|
+
project_url(commit.project, "commits", commit.identifier)
|
28
22
|
end
|
29
23
|
|
30
24
|
def commit_path(commit, *path)
|
31
|
-
|
25
|
+
commit_url(commit).path
|
32
26
|
end
|
33
27
|
|
34
28
|
def build_path(build, *path)
|
35
|
-
warn "#build_path is deprecated, use #commit_path instead"
|
29
|
+
warn "#build_path is deprecated, use #commit_path instead (#{caller[0]})"
|
36
30
|
commit_path build.commit, *path
|
37
31
|
end
|
38
32
|
|
39
|
-
def commit_url(commit)
|
40
|
-
url commit_path(commit)
|
41
|
-
end
|
42
|
-
|
43
33
|
def build_url(build)
|
44
|
-
warn "#build_url is deprecated, use #commit_url instead"
|
34
|
+
warn "#build_url is deprecated, use #commit_url instead (#{caller[0]})"
|
45
35
|
commit_url build.commit
|
46
36
|
end
|
37
|
+
|
38
|
+
def push_url_for(project)
|
39
|
+
Addressable::URI.parse(project_url(project, "push")).tap do |url|
|
40
|
+
if Integrity.config[:use_basic_auth]
|
41
|
+
url.user = Integrity.config[:admin_username]
|
42
|
+
url.password = Integrity.config[:hash_admin_password] ?
|
43
|
+
"<password>" : Integrity.config[:admin_password]
|
44
|
+
end
|
45
|
+
end.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def url(path="")
|
50
|
+
root_url.dup.tap { |url| url.path = root_url.path + path }
|
51
|
+
end
|
52
|
+
|
53
|
+
def base_url
|
54
|
+
Integrity.config[:base_uri] || ((respond_to?(:request) &&
|
55
|
+
request.respond_to?(:url)) ? request.url : fail("set base_uri"))
|
56
|
+
end
|
47
57
|
end
|
48
58
|
end
|
49
59
|
end
|
data/lib/integrity/installer.rb
CHANGED
@@ -16,20 +16,13 @@ module Integrity
|
|
16
16
|
|
17
17
|
if options[:heroku]
|
18
18
|
cp_r Pathname(__FILE__).join("../../../config/heroku"), root
|
19
|
-
puts
|
20
|
-
Your Integrity install is ready to be deployed onto Heroku. Next steps:
|
21
|
-
|
22
|
-
1. git init && git add . && git commit -am "Initial import"
|
23
|
-
2. heroku create
|
24
|
-
3. git push heroku master
|
25
|
-
4. heroku rake db:migrate
|
26
|
-
EOF
|
19
|
+
puts post_heroku_install_message
|
27
20
|
else
|
28
21
|
create_dir_structure
|
29
22
|
copy_template_files
|
30
23
|
edit_template_files
|
31
24
|
migrate_db(root.join("config.yml"))
|
32
|
-
|
25
|
+
puts post_install_message
|
33
26
|
end
|
34
27
|
end
|
35
28
|
|
@@ -50,11 +43,8 @@ EOF
|
|
50
43
|
require "thin"
|
51
44
|
require "do_sqlite3"
|
52
45
|
|
53
|
-
|
54
|
-
Integrity.new(options[:config])
|
55
|
-
else
|
56
|
-
DataMapper.setup(:default, "sqlite3::memory:")
|
57
|
-
end
|
46
|
+
File.file?(options[:config].to_s) ?
|
47
|
+
Integrity.new(options[:config]) : Integrity.new
|
58
48
|
|
59
49
|
DataMapper.auto_migrate!
|
60
50
|
|
@@ -104,8 +94,19 @@ EOF
|
|
104
94
|
File.open(root / "thin.yml", 'w') { |f| f.puts config }
|
105
95
|
end
|
106
96
|
|
107
|
-
def
|
108
|
-
|
97
|
+
def post_heroku_install_message
|
98
|
+
<<EOF
|
99
|
+
Your Integrity install is ready to be deployed onto Heroku. Next steps:
|
100
|
+
|
101
|
+
1. git init && git add . && git commit -am "Initial import"
|
102
|
+
2. heroku create
|
103
|
+
3. git push heroku master
|
104
|
+
4. heroku rake db:migrate
|
105
|
+
EOF
|
106
|
+
end
|
107
|
+
|
108
|
+
def post_install_message
|
109
|
+
<<EOF
|
109
110
|
Awesome! Integrity was installed successfully!
|
110
111
|
|
111
112
|
If you want to enable notifiers, install the gems and then require them
|
@@ -113,7 +114,7 @@ in #{root}/config.ru
|
|
113
114
|
|
114
115
|
For example:
|
115
116
|
|
116
|
-
sudo gem install -s http://gems.github.com foca-integrity-email
|
117
|
+
sudo gem install -s http://gems.github.com foca-integrity-email
|
117
118
|
|
118
119
|
And then in #{root}/config.ru add:
|
119
120
|
|
@@ -17,7 +17,7 @@ module Integrity
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def build
|
20
|
-
warn "Notifier::Base#build is deprecated, use Notifier::Base#commit instead"
|
20
|
+
warn "Notifier::Base#build is deprecated, use Notifier::Base#commit instead (#{caller[0]})"
|
21
21
|
commit
|
22
22
|
end
|
23
23
|
|
@@ -50,6 +50,11 @@ EOM
|
|
50
50
|
Integrity.config[:base_uri] / commit.project.permalink / "commits" / commit.identifier
|
51
51
|
end
|
52
52
|
|
53
|
+
def build_url
|
54
|
+
warn "Notifier::Base#build_url is deprecated, use Notifier::Base#commit_url instead (#{caller[0]})"
|
55
|
+
commit_url
|
56
|
+
end
|
57
|
+
|
53
58
|
private
|
54
59
|
|
55
60
|
def stripped_commit_output
|
@@ -57,7 +62,7 @@ EOM
|
|
57
62
|
end
|
58
63
|
|
59
64
|
def stripped_build_output
|
60
|
-
warn "Notifier::Base#stripped_build_output is deprecated, use Notifier::base#stripped_commit_output instead"
|
65
|
+
warn "Notifier::Base#stripped_build_output is deprecated, use Notifier::base#stripped_commit_output instead (#{caller[0]})"
|
61
66
|
stripped_commit_output
|
62
67
|
end
|
63
68
|
end
|
data/lib/integrity/project.rb
CHANGED
@@ -57,7 +57,7 @@ module Integrity
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def last_build
|
60
|
-
warn "Project#last_build is deprecated, use Project#last_commit"
|
60
|
+
warn "Project#last_build is deprecated, use Project#last_commit (#{caller[0]})"
|
61
61
|
last_commit
|
62
62
|
end
|
63
63
|
|
@@ -66,7 +66,7 @@ module Integrity
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def previous_builds
|
69
|
-
warn "Project#previous_builds is deprecated, use Project#previous_commits"
|
69
|
+
warn "Project#previous_builds is deprecated, use Project#previous_commits (#{caller[0]})"
|
70
70
|
previous_commits
|
71
71
|
end
|
72
72
|
|
data/test/acceptance/api_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/
|
1
|
+
require File.dirname(__FILE__) + "/../helpers/acceptance"
|
2
2
|
require "integrity/installer"
|
3
3
|
|
4
4
|
class InstallerTest < Test::Unit::AcceptanceTestCase
|
@@ -65,11 +65,7 @@ class InstallerTest < Test::Unit::AcceptanceTestCase
|
|
65
65
|
scenario "Installing Integrity for Heroku" do
|
66
66
|
message = install("--heroku")
|
67
67
|
|
68
|
-
|
69
|
-
assert gemifest.include?("mailfactory")
|
70
|
-
assert gemifest.include?("tlsmail")
|
71
|
-
assert gemifest.include?("foca-sinatra-ditties")
|
72
|
-
assert gemifest.include?("integrity")
|
68
|
+
assert_equal "integrity --version 0.1.9.0", root.join(".gems").read.chomp
|
73
69
|
|
74
70
|
assert root.join("Rakefile").file?
|
75
71
|
assert root.join("integrity-config.rb").file?
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helpers/acceptance"
|
2
|
+
|
3
|
+
class NotFoundPageTest < Test::Unit::AcceptanceTestCase
|
4
|
+
story <<-EOS
|
5
|
+
As an visitor,
|
6
|
+
I want to be shown a friendly four oh four
|
7
|
+
So that I DON'T HAVE TO THINK.
|
8
|
+
EOS
|
9
|
+
|
10
|
+
scenario "chilling on some Integrity instance found via The Holy Hub" do
|
11
|
+
project = Project.gen
|
12
|
+
|
13
|
+
visit "/42"
|
14
|
+
assert_equal 404, response_code
|
15
|
+
|
16
|
+
click_link "list of projects"
|
17
|
+
assert_contain(project.name)
|
18
|
+
|
19
|
+
visit "/42"
|
20
|
+
|
21
|
+
click_link "the projects list"
|
22
|
+
assert_contain(project.name)
|
23
|
+
|
24
|
+
visit "/42"
|
25
|
+
|
26
|
+
click_link "back from whence you came"
|
27
|
+
assert_contain("Add a new project")
|
28
|
+
end
|
29
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/
|
1
|
+
require File.dirname(__FILE__) + "/../helpers/acceptance"
|
2
2
|
|
3
3
|
class IntegrityStylesheetTest < Test::Unit::AcceptanceTestCase
|
4
4
|
story <<-EOS
|
@@ -8,11 +8,19 @@ class IntegrityStylesheetTest < Test::Unit::AcceptanceTestCase
|
|
8
8
|
EOS
|
9
9
|
|
10
10
|
scenario "browsing on some Integrity install" do
|
11
|
+
visit "/"
|
12
|
+
assert_have_tag("link[@href='/integrity.css']")
|
11
13
|
visit "/integrity.css"
|
12
14
|
|
13
15
|
assert_contain("body {")
|
14
|
-
# TODO:
|
16
|
+
# TODO: Check that it actually returns a 302
|
15
17
|
assert_equal %Q{"2465c472aacf302259dde5146a841e45"},
|
16
18
|
webrat_session.send(:response).headers["ETag"]
|
19
|
+
|
20
|
+
visit "/reset.css"
|
21
|
+
assert_contain("Yahoo!")
|
22
|
+
|
23
|
+
visit "/buttons.css"
|
24
|
+
assert_contain("button {")
|
17
25
|
end
|
18
26
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../helpers/acceptance"
|
2
|
+
|
3
|
+
class UnauthorizedPageTest < Test::Unit::AcceptanceTestCase
|
4
|
+
story <<-EOS
|
5
|
+
As an administrator,
|
6
|
+
I want to be shown a friendly login error page
|
7
|
+
So that I don't feel guilty of loosing my password
|
8
|
+
EOS
|
9
|
+
|
10
|
+
scenario "an administrator (who's amnesiac) tries to login" do
|
11
|
+
project = Project.gen(:public => false)
|
12
|
+
|
13
|
+
visit "/#{project.name}/edit"
|
14
|
+
assert_equal 401, response_code
|
15
|
+
|
16
|
+
# TODO click_link "try again"
|
17
|
+
assert_have_tag("a[@href='/login']", :content => "try again")
|
18
|
+
assert_have_tag("a[@href='/']", :content => "go back")
|
19
|
+
end
|
20
|
+
end
|
data/test/helpers.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__) + "/../lib", File.dirname(__FILE__)
|
2
|
-
File.dirname(__FILE__) + "/../vendor/webrat/lib"
|
1
|
+
$:.unshift File.dirname(__FILE__) + "/../lib", File.dirname(__FILE__)
|
3
2
|
|
4
3
|
%w(test/unit
|
5
4
|
context
|
@@ -9,19 +8,18 @@ storyteller
|
|
9
8
|
webrat/sinatra
|
10
9
|
rr
|
11
10
|
mocha
|
12
|
-
test/zentest_assertions
|
13
11
|
dm-sweatshop).each { |dependency|
|
14
12
|
begin
|
15
13
|
require dependency
|
16
|
-
rescue LoadError
|
14
|
+
rescue LoadError => e
|
17
15
|
puts "You're missing some gems required to run the tests."
|
18
|
-
puts "Please run `rake test:
|
19
|
-
puts "You'll probably need to run that command as root or with sudo."
|
16
|
+
puts "Please run `rake test:setup`"
|
17
|
+
puts "NOTE: You'll probably need to run that command as root or with sudo."
|
20
18
|
|
21
19
|
puts "Thanks :)"
|
22
20
|
puts
|
23
21
|
|
24
|
-
|
22
|
+
raise
|
25
23
|
end
|
26
24
|
}
|
27
25
|
|
@@ -39,6 +37,14 @@ module TestHelper
|
|
39
37
|
def ignore_logs!
|
40
38
|
Integrity.config[:log] = "/tmp/integrity.test.log"
|
41
39
|
end
|
40
|
+
|
41
|
+
def util_capture
|
42
|
+
output = StringIO.new
|
43
|
+
$stdout = output
|
44
|
+
yield
|
45
|
+
$stdout = STDOUT
|
46
|
+
output
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
class Test::Unit::TestCase
|
data/test/helpers/acceptance.rb
CHANGED
data/test/unit/build_test.rb
CHANGED
@@ -36,6 +36,16 @@ class BuildTest < Test::Unit::TestCase
|
|
36
36
|
@build.successful = false
|
37
37
|
@build.status.should be(:failed)
|
38
38
|
end
|
39
|
+
|
40
|
+
test "deprecated properties" do
|
41
|
+
@build.short_commit_identifier.should == @build.commit.short_identifier
|
42
|
+
@build.commit_identifier.should == @build.commit.identifier
|
43
|
+
@build.commit_author.should == @build.commit.author
|
44
|
+
@build.commit_message.should == @build.commit.message
|
45
|
+
@build.commited_at.should == @build.commit.committed_at
|
46
|
+
@build.project_id.should == @build.commit.project_id
|
47
|
+
@build.should respond_to(:commit_metadata)
|
48
|
+
end
|
39
49
|
end
|
40
50
|
|
41
51
|
describe "Pending builds" do
|