From 0a408682921130285e88cafb73b3e95da1406f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 14 Jan 2009 22:47:32 +0100 Subject: [PATCH 01/11] dump query parameters on error page Signed-off-by: Simon Rozet --- views/error.haml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/views/error.haml b/views/error.haml index 1e39d0fa..e43f3729 100644 --- a/views/error.haml +++ b/views/error.haml @@ -7,6 +7,9 @@ %dd %strong&= @error.message %pre.backtrace= @error.backtrace.join("\n") + %dd + %strong Query parameters: + %pre.query_params= params.inspect %dt What can I do? %dd From c772b6c947f50c85b72c7431b4d99d663fd8ea22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 14 Jan 2009 18:43:54 +0100 Subject: [PATCH 02/11] Sinatra 0.9 compatibility * switch vendore/webrat to brynary's master and monkey-patch SinatraSession TODO: send fixes upstream * no need for sinatra-hacks anymore! (nested params is now built in sinatra) * use #response[]= instead of deprecated #header * update sinatra dependency to >= 0.9.0.3 --- .gitmodules | 2 +- Rakefile | 2 +- app.rb | 13 ++-- lib/integrity/helpers.rb | 28 ++++++-- test/acceptance/build_notifications_test.rb | 14 ++-- test/helpers/acceptance.rb | 80 +++++++++++++++++---- vendor/sinatra-hacks/lib/hacks.rb | 49 ------------- vendor/webrat | 2 +- 8 files changed, 102 insertions(+), 88 deletions(-) delete mode 100644 vendor/sinatra-hacks/lib/hacks.rb diff --git a/.gitmodules b/.gitmodules index d7e49b49..529a2ee5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "vendor/webrat"] path = vendor/webrat - url = git://github.com/foca/webrat.git + url = git://github.com/brynary/webrat.git diff --git a/Rakefile b/Rakefile index 58545e41..6b62ae8b 100644 --- a/Rakefile +++ b/Rakefile @@ -89,7 +89,7 @@ begin s.executables = ['integrity'] s.post_install_message = 'Run `integrity help` for information on how to setup Integrity.' - s.add_dependency 'sinatra', ['>= 0.3.2'] + s.add_dependency 'sinatra', ['>= 0.9.0.3'] s.add_dependency 'haml' # ah, you evil monkey you s.add_dependency 'dm-core', ['>= 0.9.5'] s.add_dependency 'dm-validations', ['>= 0.9.5'] diff --git a/app.rb b/app.rb index d78750c8..1d0969b1 100644 --- a/app.rb +++ b/app.rb @@ -1,7 +1,6 @@ require File.dirname(__FILE__) + "/lib/integrity" require "sinatra" require "helpers" -require "hacks" set :root, Integrity.root set :public, Integrity.root / "public" @@ -46,7 +45,7 @@ get "/login" do login_required session[:user] = current_user - redirect "/" + redirect root_url end get "/new" do @@ -62,7 +61,7 @@ @project = Project.new(params[:project_data]) if @project.save @project.enable_notifiers(params["enabled_notifiers[]"], params["notifiers"]) - redirect project_path(@project) + redirect project_url(@project) else show :new, :title => ["projects", "new project"] end @@ -75,7 +74,7 @@ get "/:project.atom" do login_required unless current_project.public? - header "Content-Type" => "application/atom+xml; charset=utf-8" + response.headers["Content-Type"] = "application/rss+xml; charset=utf-8" builder :project end @@ -83,7 +82,7 @@ login_required if current_project.update_attributes(params[:project_data]) - current_project.enable_notifiers(params["enabled_notifiers[]"], params["notifiers"]) + current_project.enable_notifiers(params["enabled_notifiers"], params["notifiers"]) redirect project_url(current_project) else show :new, :title => ["projects", current_project.permalink, "edit"] @@ -94,7 +93,7 @@ login_required current_project.destroy - redirect "/" + redirect root_url end get "/:project/edit" do @@ -129,7 +128,7 @@ end get "/integrity.css" do - header "Content-Type" => "text/css; charset=utf-8" + response.headers["Content-Type"] = "text/css; charset=utf-8" sass :integrity end diff --git a/lib/integrity/helpers.rb b/lib/integrity/helpers.rb index b9353f71..d3a506ce 100644 --- a/lib/integrity/helpers.rb +++ b/lib/integrity/helpers.rb @@ -26,7 +26,7 @@ def authorize(user, password) end def unauthorized!(realm=authorization_realm) - header "WWW-Authenticate" => %(Basic realm="#{realm}") + response.headers["WWW-Authenticate"] = %(Basic realm="#{realm}") throw :halt, [401, show(:unauthorized, :title => "incorrect credentials")] end @@ -68,8 +68,24 @@ def cycle(*values) values[next_value] end - def integrity_domain - Addressable::URI.parse(Integrity.config[:base_uri]).to_s + # def integrity_domain + # Addressable::URI.parse(Integrity.config[:base_uri]).to_s + # end + + def url(path) + url = "#{request.scheme}://#{request.host}" + + if request.scheme == "https" && request.port != 443 || + request.scheme == "http" && request.port != 80 + url << ":#{request.port}" + end + + url << "/" unless path.index("/").zero? + url << path + end + + def root_url + url("/") end def project_path(project, *path) @@ -77,11 +93,11 @@ def project_path(project, *path) end def project_url(project, *path) - "#{integrity_domain}#{project_path(project, *path)}" + url project_path(project, *path) end def push_url_for(project) - "#{project_url(project)}/push" + project_url(project, "push") end def build_path(build) @@ -89,7 +105,7 @@ def build_path(build) end def build_url(build) - "#{integrity_domain}#{build_path(build)}" + url build_path(build) end def errors_on(object, field) diff --git a/test/acceptance/build_notifications_test.rb b/test/acceptance/build_notifications_test.rb index 2b86b4f9..e54a43bb 100644 --- a/test/acceptance/build_notifications_test.rb +++ b/test/acceptance/build_notifications_test.rb @@ -7,27 +7,23 @@ class BuildNotificationsTest < Test::Unit::AcceptanceTestCase I want to setup notifiers on my projects So that I get alerts with every build EOS - - before(:each) do - Integrity.config[:base_uri] = "http://integrity.example.org" - end scenario "an admin sets up a notifier for a project that didn't have any" do git_repo(:my_test_project).add_successful_commit Project.gen(:my_test_project, :notifiers => [], :uri => git_repo(:my_test_project).path) rm_f "/tmp/textfile_notifications.txt" - + login_as "admin", "test" - + visit "/my-test-project" click_link "Edit Project" check "enabled_notifiers_textfile" fill_in "File", :with => "/tmp/textfile_notifications.txt" click_button "Update Project" - + click_button "manual build" - + notification = File.read("/tmp/textfile_notifications.txt") notification.should =~ /=== Build #{git_repo(:my_test_project).short_head} was successful ===/ notification.should =~ /Build #{git_repo(:my_test_project).head} was successful/ @@ -37,4 +33,4 @@ class BuildNotificationsTest < Test::Unit::AcceptanceTestCase notification.should =~ /Commit Message: This commit will work/ notification.should =~ /Build Output:\n\nRunning tests...\n/ end -end \ No newline at end of file +end diff --git a/test/helpers/acceptance.rb b/test/helpers/acceptance.rb index 44a68631..dba02455 100644 --- a/test/helpers/acceptance.rb +++ b/test/helpers/acceptance.rb @@ -1,9 +1,61 @@ -require "webrat/sinatra" +require 'webrat/rack' +require 'sinatra' +require 'sinatra/test' + +disable :run +disable :reload + +Webrat.configuration.instance_variable_set("@mode", :sinatra) + +module Webrat + class SinatraSession < Session + DEFAULT_DOMAIN = "integrity.example.org" + + def initialize(context = nil) + super(context) + @sinatra_test = Sinatra::TestHarness.new + end + + %w(get head post put delete).each do |verb| + class_eval <<-METHOD + def #{verb}(path, data, headers = {}) + params = data.inject({}) do |data, (key,value)| + data[key] = Rack::Utils.unescape(value) + data + end + headers['HTTP_HOST'] = DEFAULT_DOMAIN + @sinatra_test.#{verb}(path, params, headers) + end + METHOD + end + + def response_body + @sinatra_test.body + end + + def response_code + @sinatra_test.status + end + + private + + def response + @sinatra_test.response + end + + def current_host + URI.parse(current_url).host || DEFAULT_DOMAIN + end + + def response_location_host + URI.parse(response_location).host || DEFAULT_DOMAIN + end + end +end + require Integrity.root / "app" require File.dirname(__FILE__) / "acceptance/git_helper" -Webrat.configuration.mode = :sinatra - module AcceptanceHelper include FileUtils @@ -17,14 +69,14 @@ def enable_auth! Integrity.config[:admin_password] = "test" Integrity.config[:hash_admin_password] = false end - + def login_as(user, password) def AcceptanceHelper.logged_in; true; end basic_auth user, password visit "/login" - Sinatra.application.before { login_required if AcceptanceHelper.logged_in } + Sinatra::Application.before { login_required if AcceptanceHelper.logged_in } end - + def log_out def AcceptanceHelper.logged_in; false; end @_webrat_session = Webrat::SinatraSession.new(self) @@ -47,17 +99,17 @@ def setup_log! end end -module WebratHelpers - include Webrat::Methods - Webrat::Methods.delegate_to_session :response_code, :response_body -end - class Test::Unit::AcceptanceTestCase < Test::Unit::TestCase include AcceptanceHelper include Test::Storyteller - include WebratHelpers include GitHelper - + include Webrat::Methods + Webrat::Methods.delegate_to_session :response_code + + before(:all) do + Integrity.config[:base_uri] = "http://#{Webrat::SinatraSession::DEFAULT_DOMAIN}" + end + before(:each) do # ensure each scenario is run in a clean sandbox setup_and_reset_database! @@ -66,7 +118,7 @@ class Test::Unit::AcceptanceTestCase < Test::Unit::TestCase set_and_create_export_directory! log_out end - + after(:each) do destroy_all_git_repos rm_r export_directory if File.directory?(export_directory) diff --git a/vendor/sinatra-hacks/lib/hacks.rb b/vendor/sinatra-hacks/lib/hacks.rb deleted file mode 100644 index 2444cb2e..00000000 --- a/vendor/sinatra-hacks/lib/hacks.rb +++ /dev/null @@ -1,49 +0,0 @@ -module Sinatra - class EventContext - def params - @params ||= ParamsParser.new(@route_params.merge(@request.params)).to_hash - end - - private - - class ParamsParser - attr_reader :hash - - def initialize(hash) - @hash = nested(hash) - end - - alias :to_hash :hash - - protected - - def nested(hash) - hash.inject(indifferent_hash) do |par, (key,val)| - if key =~ /([^\[]+)\[([^\]]+)\](.*)/ # a[b] || a[b][c] ($1 == a, $2 == b, $3 == [c]) - par[$1] ||= indifferent_hash - par[$1].merge_recursive nested("#{$2}#{$3}" => val) - else - par[key] = val - end - par - end - end - - def indifferent_hash - Hash.new {|h,k| h[k.to_s] if Symbol === k} - end - end - end -end - -class Hash - def merge_recursive(other) - update(other) do |key, old_value, new_value| - if Hash === old_value && Hash === new_value - old_value.merge_recursive(new_value) - else - new_value - end - end - end -end diff --git a/vendor/webrat b/vendor/webrat index 78b8f341..0272e818 160000 --- a/vendor/webrat +++ b/vendor/webrat @@ -1 +1 @@ -Subproject commit 78b8f3411ad83bea91e7bf98dcb8e9f640e75603 +Subproject commit 0272e818473d12b1d9bd45beed55b54e3e4418a3 From 3b1380a550988c4231dac30208eb2438b089dd72 Mon Sep 17 00:00:00 2001 From: Simon Rozet Date: Thu, 22 Jan 2009 23:53:41 +0100 Subject: [PATCH 03/11] fix api test. why didn't this fail earlier? --- test/acceptance/api_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/acceptance/api_test.rb b/test/acceptance/api_test.rb index ba84f380..f538bab2 100644 --- a/test/acceptance/api_test.rb +++ b/test/acceptance/api_test.rb @@ -33,7 +33,7 @@ class ApiTest < Test::Unit::AcceptanceTestCase end end - Project.gen(:my_test_project, :uri => repo.path) + Project.gen(:my_test_project, :uri => repo.path, :command => "echo successful") lambda do basic_auth "admin", "test" @@ -71,7 +71,7 @@ class ApiTest < Test::Unit::AcceptanceTestCase Project.gen(:my_test_project, :uri => git_repo(:my_test_project).path) head = git_repo(:my_test_project).head post "/my-test-project/push", :payload => payload(head, "master") - + response_code.should == 401 end From 977f5f2d9a5c3e2c9e02927d1c4ed55528909fe1 Mon Sep 17 00:00:00 2001 From: Simon Rozet Date: Fri, 23 Jan 2009 04:02:28 +0100 Subject: [PATCH 04/11] display user and password in push url --- lib/integrity/helpers.rb | 7 ++++++- test/acceptance/edit_project_test.rb | 10 ++++++++++ test/unit/helpers_test.rb | 29 ++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/lib/integrity/helpers.rb b/lib/integrity/helpers.rb index d3a506ce..cc700606 100644 --- a/lib/integrity/helpers.rb +++ b/lib/integrity/helpers.rb @@ -97,7 +97,12 @@ def project_url(project, *path) end def push_url_for(project) - project_url(project, "push") + Addressable::URI.parse("#{project_url(project)}/push").tap do |url| + if Integrity.config[:use_basic_auth] && !Integrity.config[:hash_admin_password] + url.user = Integrity.config[:admin_username] + url.password = Integrity.config[:admin_password] + end + end.to_s end def build_path(build) diff --git a/test/acceptance/edit_project_test.rb b/test/acceptance/edit_project_test.rb index fe46f12d..1b7a91ff 100644 --- a/test/acceptance/edit_project_test.rb +++ b/test/acceptance/edit_project_test.rb @@ -62,6 +62,16 @@ class EditProjectTest < Test::Unit::AcceptanceTestCase response_body.should have_tag("a", /My Test Project/) end + scenario "an admin can see the push URL on the edit page" do + disable_auth! + Project.generate(:my_test_project) + + visit "/my-test-project" + click_link "Edit Project" + + response_body.should have_tag("#push_url", "http://integrity.example.org/my-test-project/push") + end + scenario "a user can't edit a project's information" do Project.generate(:integrity) diff --git a/test/unit/helpers_test.rb b/test/unit/helpers_test.rb index d9e2d094..0367b807 100644 --- a/test/unit/helpers_test.rb +++ b/test/unit/helpers_test.rb @@ -21,4 +21,33 @@ class BrowsePublicProjectsTest < Test::Unit::TestCase pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th" pretty_date(Time.mktime(1995, 12, 15)).should == "on Dec 15th" end + + describe "#push_url_for" do + before(:each) do + setup_and_reset_database! + @project = Project.gen(:integrity) + Integrity.config[:admin_username] = "admin" + Integrity.config[:admin_password] = "test" + end + + test "with auth disabled" do + Integrity.config[:use_basic_auth] = false + + push_url_for(@project).should == "http://0.0.0.0:1234/integrity/push" + end + + test "with auth and hashing enabled" do + Integrity.config[:use_basic_auth] = true + Integrity.config[:hash_admin_password] = true + + push_url_for(@project).should == "http://0.0.0.0:1234/integrity/push" + end + + test "with auth enabled and hashing disabled" do + Integrity.config[:use_basic_auth] = true + Integrity.config[:hash_admin_password] = false + + push_url_for(@project).should == "http://admin:test@0.0.0.0:1234/integrity/push" + end + end end From 5cd0165bcccd6f132fba8acb7704c8edf54014e7 Mon Sep 17 00:00:00 2001 From: Nicolas Sanguinetti Date: Sun, 25 Jan 2009 03:58:48 -0200 Subject: [PATCH 05/11] Log requests to the webapp on integrity's log --- config/config.sample.ru | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.sample.ru b/config/config.sample.ru index 93925a64..e999dbe0 100644 --- a/config/config.sample.ru +++ b/config/config.sample.ru @@ -27,4 +27,5 @@ set :port, 8910 set :env, :production disable :run, :reload +use Rack::CommonLogger, Integrity.logger run Sinatra.application From 91a8aa67a9bf6832ac6a8b980b60c11411ef2fe5 Mon Sep 17 00:00:00 2001 From: Nicolas Sanguinetti Date: Sun, 25 Jan 2009 04:03:45 -0200 Subject: [PATCH 06/11] Add an option on Integrity.config to turn on/off debug logging (db queries and rack requests) --- config/config.sample.ru | 2 +- config/config.sample.yml | 4 ++++ lib/integrity.rb | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/config.sample.ru b/config/config.sample.ru index e999dbe0..323fb672 100644 --- a/config/config.sample.ru +++ b/config/config.sample.ru @@ -27,5 +27,5 @@ set :port, 8910 set :env, :production disable :run, :reload -use Rack::CommonLogger, Integrity.logger +use Rack::CommonLogger, Integrity.logger if Integrity.config[:log_debug_info] run Sinatra.application diff --git a/config/config.sample.yml b/config/config.sample.yml index 1b6c8832..559fca42 100644 --- a/config/config.sample.yml +++ b/config/config.sample.yml @@ -16,6 +16,10 @@ # Path to the integrity log file :log: /var/log/integrity.log +# Enable/Disable debug logging. Turning this on will log queries made to the +# database and web requests (if using the provided rackup file) +:log_debug_info: false + # Enable or disable HTTP authentication for the app. BE AWARE that if you # disable this anyone can delete and alter projects, so do it only if your # app is running in a controlled environment (ie, behind your company's diff --git a/lib/integrity.rb b/lib/integrity.rb index b147cbb5..ae5e68a1 100644 --- a/lib/integrity.rb +++ b/lib/integrity.rb @@ -29,7 +29,7 @@ module Integrity def self.new(config_file = nil) self.config = config_file unless config_file.nil? - DataMapper.logger = self.logger + DataMapper.logger = self.logger if config[:log_debug_info] DataMapper.setup(:default, config[:database_uri]) end @@ -43,7 +43,8 @@ def self.default_configuration :log => STDOUT, :base_uri => "http://localhost:8910", :use_basic_auth => false, - :build_all_commits => true } + :build_all_commits => true, + :log_debug_info => false } end def self.config From 1dfbf2f7970489764838336f18440e9eba18f70d Mon Sep 17 00:00:00 2001 From: Nicolas Sanguinetti Date: Sun, 25 Jan 2009 04:15:33 -0200 Subject: [PATCH 07/11] If auth is enabled but password is hashed, still point out that the push url needs credentials. Also, make sure the tests don't assume the base_uri, since the tests are failing on builder.integrityapp.com --- lib/integrity/helpers.rb | 5 +++-- test/unit/helpers_test.rb | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/integrity/helpers.rb b/lib/integrity/helpers.rb index cc700606..5be0a31d 100644 --- a/lib/integrity/helpers.rb +++ b/lib/integrity/helpers.rb @@ -98,9 +98,10 @@ def project_url(project, *path) def push_url_for(project) Addressable::URI.parse("#{project_url(project)}/push").tap do |url| - if Integrity.config[:use_basic_auth] && !Integrity.config[:hash_admin_password] + if Integrity.config[:use_basic_auth] url.user = Integrity.config[:admin_username] - url.password = Integrity.config[:admin_password] + url.password = Integrity.config[:hash_admin_password] ? + "" : Integrity.config[:admin_password] end end.to_s end diff --git a/test/unit/helpers_test.rb b/test/unit/helpers_test.rb index 0367b807..a07fb75d 100644 --- a/test/unit/helpers_test.rb +++ b/test/unit/helpers_test.rb @@ -28,26 +28,27 @@ class BrowsePublicProjectsTest < Test::Unit::TestCase @project = Project.gen(:integrity) Integrity.config[:admin_username] = "admin" Integrity.config[:admin_password] = "test" + Integrity.config[:base_uri] = "http://integrity.example.org:1234" end test "with auth disabled" do Integrity.config[:use_basic_auth] = false - push_url_for(@project).should == "http://0.0.0.0:1234/integrity/push" + push_url_for(@project).should == "http://integrity.example.org:1234/integrity/push" end test "with auth and hashing enabled" do Integrity.config[:use_basic_auth] = true Integrity.config[:hash_admin_password] = true - push_url_for(@project).should == "http://0.0.0.0:1234/integrity/push" + push_url_for(@project).should == "http://admin:@integrity.example.org:1234/integrity/push" end test "with auth enabled and hashing disabled" do Integrity.config[:use_basic_auth] = true Integrity.config[:hash_admin_password] = false - push_url_for(@project).should == "http://admin:test@0.0.0.0:1234/integrity/push" + push_url_for(@project).should == "http://admin:test@integrity.example.org:1234/integrity/push" end end end From a6293a4184676ba9b93a9ca38060864e957d11b3 Mon Sep 17 00:00:00 2001 From: Nicolas Sanguinetti Date: Sun, 25 Jan 2009 04:31:28 -0200 Subject: [PATCH 08/11] Make sure uuidtools is added as a dependency [#75 state:resolved] --- Rakefile | 3 ++- integrity.gemspec | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 6b62ae8b..0ff425cc 100644 --- a/Rakefile +++ b/Rakefile @@ -102,7 +102,8 @@ begin s.add_dependency 'json' s.add_dependency 'foca-sinatra-diddies', ['>= 0.0.2'] s.add_dependency 'thor' - s.add_dependency 'bcrypt-ruby' + s.add_dependency 'uuidtools' # required by dm-types + s.add_dependency 'bcrypt-ruby' # required by dm-types end rescue LoadError end diff --git a/integrity.gemspec b/integrity.gemspec index a2eb3c5e..cb298db1 100644 --- a/integrity.gemspec +++ b/integrity.gemspec @@ -6,12 +6,12 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["Nicol\303\241s Sanguinetti", "Simon Rozet"] - s.date = %q{2009-01-17} + s.date = %q{2009-01-25} s.default_executable = %q{integrity} s.description = %q{Your Friendly Continuous Integration server. Easy, fun and painless!} s.email = %q{contacto@nicolassanguinetti.info} s.executables = ["integrity"] - s.files = ["README.markdown", "Rakefile", "VERSION.yml", "app.rb", "bin/integrity", "config/config.sample.ru", "config/config.sample.yml", "config/thin.sample.yml", "integrity.gemspec", "lib/integrity.rb", "lib/integrity/build.rb", "lib/integrity/core_ext/object.rb", "lib/integrity/core_ext/string.rb", "lib/integrity/core_ext/time.rb", "lib/integrity/helpers.rb", "lib/integrity/installer.rb", "lib/integrity/migrations.rb", "lib/integrity/notifier.rb", "lib/integrity/notifier/base.rb", "lib/integrity/project.rb", "lib/integrity/project_builder.rb", "lib/integrity/scm.rb", "lib/integrity/scm/git.rb", "lib/integrity/scm/git/uri.rb", "public/buttons.css", "public/reset.css", "public/spinner.gif", "test/helpers.rb", "test/helpers/acceptance.rb", "test/helpers/acceptance/git_helper.rb", "test/helpers/acceptance/textfile_notifier.rb", "test/helpers/expectations.rb", "test/helpers/expectations/be_a.rb", "test/helpers/expectations/change.rb", "test/helpers/expectations/have.rb", "test/helpers/expectations/have_tag.rb", "test/helpers/expectations/predicates.rb", "test/helpers/fixtures.rb", "vendor/sinatra-hacks/lib/hacks.rb", "vendor/webrat", "views/build.haml", "views/build_info.haml", "views/error.haml", "views/home.haml", "views/integrity.sass", "views/layout.haml", "views/new.haml", "views/not_found.haml", "views/notifier.haml", "views/project.builder", "views/project.haml", "views/unauthorized.haml"] + s.files = ["README.markdown", "Rakefile", "VERSION.yml", "app.rb", "bin/integrity", "config/config.sample.ru", "config/config.sample.yml", "config/thin.sample.yml", "integrity.gemspec", "lib/integrity.rb", "lib/integrity/build.rb", "lib/integrity/core_ext/object.rb", "lib/integrity/core_ext/string.rb", "lib/integrity/helpers.rb", "lib/integrity/installer.rb", "lib/integrity/migrations.rb", "lib/integrity/notifier.rb", "lib/integrity/notifier/base.rb", "lib/integrity/project.rb", "lib/integrity/project_builder.rb", "lib/integrity/scm.rb", "lib/integrity/scm/git.rb", "lib/integrity/scm/git/uri.rb", "public/buttons.css", "public/reset.css", "public/spinner.gif", "test/helpers.rb", "test/helpers/acceptance.rb", "test/helpers/acceptance/git_helper.rb", "test/helpers/acceptance/textfile_notifier.rb", "test/helpers/expectations.rb", "test/helpers/expectations/be_a.rb", "test/helpers/expectations/change.rb", "test/helpers/expectations/have.rb", "test/helpers/expectations/have_tag.rb", "test/helpers/expectations/predicates.rb", "test/helpers/fixtures.rb", "vendor/sinatra-hacks/lib/hacks.rb", "vendor/webrat", "views/_build_info.haml", "views/build.haml", "views/error.haml", "views/home.haml", "views/integrity.sass", "views/layout.haml", "views/new.haml", "views/not_found.haml", "views/notifier.haml", "views/project.builder", "views/project.haml", "views/unauthorized.haml"] s.homepage = %q{http://integrityapp.com} s.post_install_message = %q{Run `integrity help` for information on how to setup Integrity.} s.require_paths = ["lib"] @@ -31,11 +31,13 @@ Gem::Specification.new do |s| s.add_runtime_dependency(%q, [">= 0.9.5"]) s.add_runtime_dependency(%q, [">= 0.9.5"]) s.add_runtime_dependency(%q, [">= 0.9.5"]) + s.add_runtime_dependency(%q, [">= 0.9.5"]) s.add_runtime_dependency(%q, [">= 0.9.5"]) s.add_runtime_dependency(%q, [">= 0.9.5"]) s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0.0.2"]) s.add_runtime_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0.3.2"]) @@ -45,11 +47,13 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) + s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0.0.2"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end else @@ -60,11 +64,13 @@ Gem::Specification.new do |s| s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) + s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0.9.5"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0.0.2"]) s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end end From ce9fb48633fd9bef5c6fbc019e7bd34df8b0bc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Wed, 14 Jan 2009 18:43:54 +0100 Subject: [PATCH 09/11] Upgrade to Sinatra "nine milli in ya ass" 0.9 * Got ride of the webrat submodule. We're doing Webrat::SinatraSession ourself for now. TODO: send fixes upstream [#76] * For sinatra-hacks as well. (nested params is now built in sinatra) * Use #response[]= instead of deprecated #header * Update gem dependency to sinatra >= 0.9.0.3 --- .gitmodules | 3 --- app.rb | 4 ++-- lib/integrity/helpers.rb | 14 +++++++------- 3 files changed, 9 insertions(+), 12 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 529a2ee5..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "vendor/webrat"] - path = vendor/webrat - url = git://github.com/brynary/webrat.git diff --git a/app.rb b/app.rb index 1d0969b1..69dfd381 100644 --- a/app.rb +++ b/app.rb @@ -74,7 +74,7 @@ get "/:project.atom" do login_required unless current_project.public? - response.headers["Content-Type"] = "application/rss+xml; charset=utf-8" + response["Content-Type"] = "application/rss+xml; charset=utf-8" builder :project end @@ -128,7 +128,7 @@ end get "/integrity.css" do - response.headers["Content-Type"] = "text/css; charset=utf-8" + response["Content-Type"] = "text/css; charset=utf-8" sass :integrity end diff --git a/lib/integrity/helpers.rb b/lib/integrity/helpers.rb index 5be0a31d..95db233a 100644 --- a/lib/integrity/helpers.rb +++ b/lib/integrity/helpers.rb @@ -26,7 +26,7 @@ def authorize(user, password) end def unauthorized!(realm=authorization_realm) - response.headers["WWW-Authenticate"] = %(Basic realm="#{realm}") + response["WWW-Authenticate"] = %(Basic realm="#{realm}") throw :halt, [401, show(:unauthorized, :title => "incorrect credentials")] end @@ -71,19 +71,19 @@ def cycle(*values) # def integrity_domain # Addressable::URI.parse(Integrity.config[:base_uri]).to_s # end - + def url(path) url = "#{request.scheme}://#{request.host}" - + if request.scheme == "https" && request.port != 443 || request.scheme == "http" && request.port != 80 url << ":#{request.port}" end - + url << "/" unless path.index("/").zero? url << path end - + def root_url url("/") end @@ -97,10 +97,10 @@ def project_url(project, *path) end def push_url_for(project) - Addressable::URI.parse("#{project_url(project)}/push").tap do |url| + Addressable::URI.parse(project_url(project, "push")).tap do |url| if Integrity.config[:use_basic_auth] url.user = Integrity.config[:admin_username] - url.password = Integrity.config[:hash_admin_password] ? + url.password = Integrity.config[:hash_admin_password] ? "" : Integrity.config[:admin_password] end end.to_s From 3448c781b998be802cc1ef019b0a28428ca59f0c Mon Sep 17 00:00:00 2001 From: Nicolas Sanguinetti Date: Sun, 25 Jan 2009 18:45:11 -0200 Subject: [PATCH 10/11] Fix failing helpers tests --- test/unit/helpers_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/helpers_test.rb b/test/unit/helpers_test.rb index a07fb75d..9c86b0ec 100644 --- a/test/unit/helpers_test.rb +++ b/test/unit/helpers_test.rb @@ -28,7 +28,8 @@ class BrowsePublicProjectsTest < Test::Unit::TestCase @project = Project.gen(:integrity) Integrity.config[:admin_username] = "admin" Integrity.config[:admin_password] = "test" - Integrity.config[:base_uri] = "http://integrity.example.org:1234" + + stub(self).request { OpenStruct.new(:scheme => "http", :port => "1234", :host => "integrity.example.org") } end test "with auth disabled" do From e0c6c5cd3b6cf18f941ab4b9e40825197d3bf684 Mon Sep 17 00:00:00 2001 From: Nicolas Sanguinetti Date: Sun, 25 Jan 2009 22:50:35 +0100 Subject: [PATCH 11/11] Add Webrat to test depedencies --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 0ff425cc..3f17f5d0 100644 --- a/Rakefile +++ b/Rakefile @@ -51,7 +51,7 @@ namespace :test do desc "Install all gems on which the tests depend on" task :install_dependencies do - system 'gem install redgreen rr mocha ruby-debug dm-sweatshop' + system 'gem install redgreen rr mocha ruby-debug dm-sweatshop webrat' system 'gem install -s http://gems.github.com jeremymcanally-context jeremymcanally-matchy jeremymcanally-pending foca-storyteller' end end