Permalink
Browse files

Upgraded to Rails 3.

  • Loading branch information...
1 parent 8b5793b commit fc940604013cce531695f7b0af570f0ffaeb6d5d @bguthrie bguthrie committed May 3, 2011
Showing with 4,198 additions and 2,478 deletions.
  1. +1 −0 .gitignore
  2. +7 −7 Gemfile
  3. +1 −3 README.rdoc
  4. +3 −11 Rakefile
  5. +1 −1 app/controllers/builds_controller.rb
  6. +5 −8 app/controllers/projects_controller.rb
  7. +4 −4 app/helpers/application_helper.rb
  8. +3 −4 app/helpers/builds_helper.rb
  9. +1 −2 app/models/build.rb
  10. +15 −14 app/models/build_mailer.rb
  11. +2 −2 app/views/builds/drop_down.html.erb
  12. +10 −10 app/views/builds/show.html.erb
  13. +1 −1 app/views/documentation/_footer.html.erb
  14. +1 −1 app/views/documentation/_header.html.erb
  15. +1 −1 app/views/documentation/plugins.html.erb
  16. +1 −1 app/views/layouts/_header.html.erb
  17. +1 −1 app/views/layouts/application.html.erb
  18. +2 −11 app/views/projects/_project.html.erb
  19. +1 −6 app/views/projects/index.html.erb
  20. +2 −2 app/views/projects/new.html.erb
  21. +4 −0 config.ru
  22. +73 −0 config/application.rb
  23. +4 −112 config/boot.rb
  24. +1 −1 config/configuration.rb
  25. +4 −63 config/environment.rb
  26. +6 −2 config/environments/add_project.rb
  27. +9 −6 config/environments/builder.rb
  28. +25 −20 config/environments/development.rb
  29. +22 −22 config/environments/production.rb
  30. +20 −16 config/environments/test.rb
  31. +1 −0 config/initializers/cookie_verification_secret.rb
  32. +0 −19 config/initializers/new_rails_defaults.rb
  33. +1 −15 config/initializers/session_store.rb
  34. +27 −21 config/routes.rb
  35. +2 −2 config/site_config.rb_example
  36. +4 −2 cruise
  37. +3 −4 cruise_config.rb
  38. +3 −3 lib/builder_plugins/email_notifier.rb
  39. +9 −2 lib/cruise_control/init.rb
  40. +0 −11 lib/cruise_control/version.rb
  41. +0 −100 lib/smtp_tls.rb
  42. +33 −10 public/javascripts/application.js
  43. +5 −3 public/javascripts/controls.js
  44. +7 −6 public/javascripts/dragdrop.js
  45. +8 −13 public/javascripts/effects.js
  46. +3,381 −1,700 public/javascripts/prototype.js
  47. +191 −0 public/javascripts/rails.js
  48. +0 −4 script/about
  49. +0 −3 script/breakpointer
  50. +3 −4 script/builder
  51. +0 −3 script/dbconsole
  52. +0 −3 script/destroy
  53. +0 −3 script/generate
  54. +6 −0 script/rails
  55. +0 −3 script/runner
  56. +0 −3 script/server
  57. +3 −3 test/functional/builds_controller_test.rb
  58. +1 −1 test/functional/documentation_controller_test.rb
  59. +4 −22 test/functional/projects_controller_test.rb
  60. +2 −2 test/integration/builder_integration_test.rb
  61. +2 −2 test/integration/subversion_integration_test.rb
  62. 0 test/{ → lib}/build_factory.rb
  63. +44 −0 test/lib/fake_source_control.rb
  64. 0 test/{ → lib}/file_sandbox.rb
  65. +142 −59 test/test_helper.rb
  66. +1 −1 test/unit/application_helper_test.rb
  67. +1 −1 test/unit/build_log_parser_test.rb
  68. +2 −32 test/unit/build_mailer_test.rb
  69. +2 −2 test/unit/build_serializer_test.rb
  70. +1 −1 test/unit/build_status_test.rb
  71. +7 −7 test/unit/builder_starter_test.rb
  72. +7 −11 test/unit/builds_helper_test.rb
  73. +2 −2 test/unit/change_in_source_control_trigger_test.rb
  74. +1 −1 test/unit/command_line_test.rb
  75. +1 −1 test/unit/duration_formatter_test.rb
  76. +2 −2 test/unit/file_lock_test.rb
  77. +1 −1 test/unit/plugins/build_reaper_test.rb
  78. +2 −2 test/unit/plugins/builder_plugin_test.rb
  79. +1 −1 test/unit/plugins/builder_status_test.rb
  80. +13 −10 test/unit/plugins/email_notifier_test.rb
  81. +2 −2 test/unit/plugins/log_publisher_test.rb
  82. +1 −1 test/unit/plugins/project_logger_test.rb
  83. +2 −2 test/unit/polling_scheduler_test.rb
  84. +1 −1 test/unit/project_blocker_test.rb
  85. +2 −2 test/unit/project_config_tracker_test.rb
  86. +2 −2 test/unit/projects_migration_test.rb
  87. +21 −7 test/unit/routing_test.rb
  88. +1 −1 test/unit/scheduled_build_trigger_test.rb
  89. +0 −17 test/unit/smtp_tls_test.rb
  90. +1 −2 test/unit/source_control/abstract_adapter_test.rb
  91. +1 −1 test/unit/source_control/git/revision_test.rb
  92. +1 −1 test/unit/source_control/git_test.rb
  93. +2 −2 test/unit/source_control/subversion/revision_test.rb
  94. +1 −1 test/unit/source_control/subversion_test.rb
  95. +1 −1 test/unit/source_control_test.rb
  96. +1 −1 test/unit/successful_build_trigger_test.rb
  97. +1 −1 test/unit/time_formatter_test.rb
View
@@ -14,6 +14,7 @@ public/builds
.DS_Store
tmtags
.bundle
+vendor/plugins/rails_upgrade
# CCRB isn't intended for deployment onto a fixed platform, so checking in a lockfile (which will try to
# resolve gems on the current platform) isn't desirable.
View
@@ -1,19 +1,19 @@
source "http://rubygems.org"
-gem "haml", "3.0.13"
-gem "tzinfo", "0.3.22"
-gem "less", "1.2.21"
+gem "rails", "~> 3.0.0"
+gem "tzinfo", "~> 0.3.23"
+gem "rack", "~> 1.2.1"
+
gem "httparty", "0.6.1"
-gem "mechanize", "1.0.0"
gem "nokogiri", "1.4.2"
gem "api_cache", "0.2.0"
-gem "rails", "2.3.11"
gem "xml-simple"
group :test do
+ gem "shoulda", "~> 2.11.0"
+ gem "mechanize", "1.0.0"
gem "mocha", "0.9.8"
- gem "rack-test", "0.5.4", :require => "rack/test"
- gem "rspec_tag_matchers", "1.0.0"
+ gem "rack-test", :require => "rack/test"
gem "rcov"
end
View
@@ -8,9 +8,7 @@ CC.rb is easy to install, pleasant to use and simple to hack. It's written in Ru
=== Stuff
* Documentation: http://cruisecontrolrb.thoughtworks.com/documentation
-* Download the latest release from
- 1. http://rubyforge.org/frs/?group_id=2918
- 2. through the 'Download' button on Github (remember to pick the right tag first)
+* Download: https://github.com/thoughtworks/cruisecontrol.rb (click the Downloads button)
* Source: http://github.com/thoughtworks/cruisecontrol.rb
* Issue Tracking: https://cruisecontrolrb.lighthouseapp.com
* Mailing Lists: http://rubyforge.org/mail/?group_id=2918
View
@@ -1,26 +1,18 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+require File.expand_path('../config/application', __FILE__)
-require 'rubygems'
require 'rake'
-require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/packagetask'
require 'rake/gempackagetask'
-require 'rake/contrib/rubyforgepublisher'
-require File.dirname(__FILE__) + '/lib/cruise_control/version'
+CruiseControl::Application.load_tasks
PKG_NAME = 'cruisecontrol'
PKG_VERSION = CruiseControl::VERSION::STRING
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
-RELEASE_NAME = "REL #{PKG_VERSION}"
-
-RUBY_FORGE_PROJECT = "cruisecontrolrb"
-RUBY_FORGE_USER = "stellsmi"
-
-require 'tasks/rails'
+RELEASE_NAME = "REL #{PKG_VERSION}"
@@ -40,7 +40,7 @@ def artifact
if File.directory? path
if File.exists?(File.join(path, 'index.html'))
- redirect_to request.request_uri + '/index.html'
+ redirect_to request.fullpath + '/index.html'
else
# TODO: generate an index from directory contents
render :text => "this should be an index of #{params[:path]}"
@@ -1,11 +1,5 @@
class ProjectsController < ApplicationController
-
- verify :params => "id", :only => [:show, :build, :code],
- :render => { :text => "Project not specified",
- :status => 404 }
- verify :params => "path", :only => [:code],
- :render => { :text => "Path not specified",
- :status => 404 }
+
def index
@projects = Project.all
@@ -48,7 +42,10 @@ def build
@project.request_build rescue nil
@projects = Project.all
- respond_to { |format| format.js { render :action => 'index_js' } }
+ respond_to do |format|
+ format.html { head :ok }
+ format.js { render :action => 'index_js' }
+ end
end
def code
@@ -39,7 +39,7 @@ def build_to_text(build, with_elapsed_time = true)
elapsed_time_text = elapsed_time(build)
text += " took #{elapsed_time_text}" if (with_elapsed_time and !elapsed_time_text.empty?)
end
- return text
+ return text.html_safe
end
def link_to_build_with_elapsed_time(project, build)
@@ -49,11 +49,11 @@ def link_to_build_with_elapsed_time(project, build)
def display_builder_state(state)
case state
when 'building', 'builder_down', 'build_requested', 'source_control_error', 'queued', 'timed_out', 'error'
- "<div class=\"builder_status_#{state}\">#{state.gsub('_', ' ')}</div>"
+ content_tag :div, state.gsub('_', ' '), :class => "builder_status_#{state}"
when 'sleeping', 'checking_for_modifications'
''
else
- "<div class=\"builder_status_unknown\">#{h state}<br/>unknown state</div>"
+ content_tag :div, state + tag(:br) + "unknown state", :class => "builder_status_unknown"
end
end
@@ -63,7 +63,7 @@ def format_changeset_log(log)
def elapsed_time(build, format = :general)
begin
- "<span>#{format_seconds(build.elapsed_time, format)}</span>"
+ content_tag :span, format_seconds(build.elapsed_time, format)
rescue
'' # The build time is not present.
end
@@ -3,12 +3,11 @@ module BuildsHelper
def select_builds(builds)
return "" if builds.blank?
- options = builds.map do |build|
- "<option value='#{build.label}'>#{build_to_text(build, false)}</option>"
+ options = [ [ "Older Builds...", nil ] ] + builds.map do |build|
+ [ build_to_text(build, false), build.label ]
end
- options.unshift "<option value=''>Older Builds...</option>"
- select_tag "build", options.join, :onChange => "this.form.submit();"
+ select_tag "build", options_for_select(options), :onChange => "this.form.submit();"
end
def format_build_log(log)
View
@@ -136,8 +136,7 @@ def clear_cache
def url
dashboard_url = Configuration.dashboard_url
raise "Configuration.dashboard_url is not specified" if dashboard_url.nil? || dashboard_url.empty?
- dashboard_url + ActionController::Routing::Routes.generate(
- :controller => 'builds', :action => 'show', :project => project, :build => to_param)
+ dashboard_url + Rails.application.routes.url_helpers.build_path(:project => project, :build => to_param)
end
def artifact(path)
@@ -2,23 +2,24 @@
class BuildMailer < ActionMailer::Base
def build_report(build, recipients, from, subject, message, sent_at = Time.now)
- @subject = "[CruiseControl] #{subject}"
- @body = {
- :build => build,
- :message => message,
- :failures_and_errors => BuildLogParser.new(build.output).failures_and_errors.map { |e| formatted_error(e) } }
- @recipients = recipients
- @from = from
- @sent_on = sent_at
- @headers = {}
+ @subject = "[CruiseControl] #{subject}"
+ @build = build
+ @message = message
+ @failures_and_errors = BuildLogParser.new(build.output).failures_and_errors.map { |e| formatted_error(e) }
+ @recipients = recipients
+ @from = from
+ @sent_on = sent_at
+ @headers = {}
end
def test(recipients, sent_at = Time.now)
- @subject = 'Test CI E-mail'
- @body = {:build => nil, :message => 'Hi, mom', :failures_and_errors => []}
- @recipients = recipients
- @sent_on = sent_at
- @headers = {}
+ @subject = 'Test CI E-mail'
+ @build = nil
+ @message = 'Hi, mom'
+ @failures_and_errors = []
+ @recipients = recipients
+ @sent_on = sent_at
+ @headers = {}
end
def formatted_error(error)
@@ -1,5 +1,5 @@
<% unless @builds_for_dropdown.blank? %>
- <% form_tag({:action => 'show'}, :method => :get) do %>
- <%= select_builds(@builds_for_dropdown) %>
+ <%= form_tag({:action => 'show'}, :method => :get) do %>
+ <%= select_builds(@builds_for_dropdown) %>
<% end %>
<% end %>
@@ -4,12 +4,12 @@
<div id="navigate_build">
<% prev_build, next_build = @project.previous_build(@build), @project.next_build(@build)%>
- <%= link_to_unless !prev_build, '&lt; prev',
+ <%= link_to_unless !prev_build, "&lt; prev".html_safe,
{:project => @project, :build => prev_build}, :accesskey => 'k' %>
<strong><%= @build.abbreviated_label %></strong>
- <%= link_to_unless !next_build, 'next &gt;',
+ <%= link_to_unless !next_build, "next &gt;".html_safe,
{:project => @project, :build => next_build}, :accesskey => 'j' %>
- <%= link_to_unless !next_build, 'latest &gt;&gt;', :project => @project.name %>
+ <%= link_to_unless !next_build, "latest &gt;&gt;".html_safe, :project => @project.name %>
</div>
<% @builds_for_navigation_list.each do |build| %>
@@ -59,40 +59,40 @@
<br/>
<div class="section_open">
- <div class="section_header" onclick="toggle_section(this.parentNode)">Build Changeset</div>
+ <div class="section_header">Build Changeset</div>
<div class="section_content"><%= format_changeset_log(@build.changeset) %></div>
</div>
<% test_failures = failures_and_errors_if_any(@build.output) %>
<% if test_failures %>
<div class="section_open">
- <div class="section_header" onclick="toggle_section(this.parentNode)">Test Failures and Errors</div>
+ <div class="section_header">Test Failures and Errors</div>
<div class="section_content"><%= test_failures %></div>
</div>
<% end %>
<% plugin_errors = @build.plugin_errors %>
<% unless plugin_errors.empty? %>
<div class="section_open">
- <div class="section_header" onclick="toggle_section(this.parentNode)">Plugin Errors</div>
+ <div class="section_header">Plugin Errors</div>
<div class="section_content"><%= h plugin_errors %></div>
</div>
<% end %>
<div class="<%= @build.incomplete? ? 'section_open' : 'section_closed' %>">
- <div class="section_header" onclick="toggle_section(this.parentNode)">Build Log</div>
- <div class="section_content"><div class="logfile"><%= format_build_log(@build.output) %></div><div><%= link_to "See unformatted build log&hellip;", build_artifact_path(:project => @project.name, :build => @build.label, :path => 'build.log') %></div></div>
+ <div class="section_header">Build Log</div>
+ <div class="section_content"><div class="logfile"><%= format_build_log(@build.output) %></div><div><%= link_to "See unformatted build log&hellip;".html_safe, build_artifact_path(:project => @project.name, :build => @build.label, :path => 'build.log') %></div></div>
</div>
<% unless @build.additional_artifacts.empty? %>
<div class="section_open">
- <div class="section_header" onclick="toggle_section(this.parentNode)">Custom Build Artifacts</div>
+ <div class="section_header">Custom Build Artifacts</div>
<div class="section_content"><% @build.additional_artifacts.each do |artifact| %><div class="artifact"><%= link_to artifact, build_artifact_path(:project => @project.name, :build => @build.label, :path => artifact) %></div><% end %></div>
</div>
<% end %>
<div class="section_closed">
- <div class="section_header" onclick="toggle_section(this.parentNode)">Project Settings</div>
+ <div class="section_header">Project Settings</div>
<div class="section_content"><%= format_project_settings(@build.project_settings) %></div>
</div>
@@ -6,6 +6,6 @@
</div>
<div class="copyright">
Version <%= CruiseControl::VERSION::STRING %> |
- &copy; ThoughtWorks Copyright 2009
+ &copy; ThoughtWorks Copyright 2011
</div>
</div>
@@ -4,7 +4,7 @@
<div id="top-nav-wrapper">
<div id="top-nav">
<%= link_to image_tag("tw_open_source_small.png"), 'http://opensource.thoughtworks.com/', :id => 'tw_image_link'%>
- <%= link_to 'Main', document_path('') %> |
+ <%= link_to 'Main', document_root_path %> |
<%= link_to_download 'Download' %> |
<%= link_to 'Docs', document_path('docs') %> |
<%= link_to 'Contributing', document_path('contributing') %> |
@@ -11,7 +11,7 @@
</li>
<% end %>
- <% Dir["#{RAILS_ROOT}/lib/builder_plugins/*"].each do |plugin| %>
+ <% Dir[Rails.root.join("lib", "builder_plugins", "*")].each do |plugin| %>
<% name = File.basename(plugin) %>
<li>
<%= link_to name.sub(/\.rb$/, '').titleize, :action => 'plugins', :type => 'builtin', :name => name %>
@@ -4,7 +4,7 @@
<%= link_to_unless_current 'Dashboard', :controller => 'projects', :action => 'index' %>
</span>
<span class="menu_item">
- <%= link_to 'Documentation', document_path %>
+ <%= link_to 'Documentation', document_root_path %>
</span>
</div>
@@ -4,7 +4,7 @@
<head>
<title>CruiseControl.rb<%= @title ? " - " + @title : '' %></title>
<%= stylesheet_link_tag 'cruisecontrol', :media => 'all' %>
- <%= stylesheet_link_tag 'site', :media => 'all' if File.exists?(RAILS_ROOT + "/public/stylesheets/site.css") %>
+ <%= stylesheet_link_tag 'site', :media => 'all' if Rails.root.join("public", "stylesheets", "site.css").exist? %>
<% if @autorefresh %>
@@ -36,18 +36,9 @@
<td class="builder_control">
<div class="buttons">
- <% form_remote_tag(
- :url => { :action => 'build', :id => project },
- :before => "$('build_#{project.to_param}').disabled = true; " +
- "$('build_#{project.to_param}').className = 'build_button_disabled'; " +
- "Element.update('build_#{project.to_param}', 'Wait...')"
- ) do %>
+ <%= form_tag(build_project_path(:id => project), :class => "build_project", :"data-disable-build-now" => Configuration.disable_build_now) do %>
<div>
- <button
- <% if Configuration.disable_build_now -%>
- onclick="alert('Build Now button is disabled on this site.'); return false;"
- <% end -%>
- id="build_<%= project.to_param %>" type="submit" class="build_button" value="txt" title="Build Now">
+ <button type="submit" class="build_button">
<% if project.builder_state_and_activity == 'builder_down' %>
Start Builder
<% else %>
@@ -1,15 +1,10 @@
<% @rss_feeds = { 'All projects' => {:controller => 'projects', :action => 'index', :format => 'rss'} } -%>
<% @projects.each { |p| @rss_feeds["#{p.name} builds"] = project_url(:controller => 'projects', :action => 'show', :id => p, :format => 'rss')} -%>
-<div id="projects">
+<div id="projects" data-refresh-path="<%= projects_path(:format => "js") %>" data-refresh-interval="<%= Configuration.dashboard_refresh_interval.to_i * 1000 %>">
<% @projects.each do |project| -%>
<%= render :partial => 'project', :locals => {:project => project }%>
<% end -%>
<%= render :partial => 'no_projects' if @projects.empty? %>
</div>
-
-<%=
- periodically_call_remote :url => { :action => 'index', :format => 'js'}, :method => 'get',
- :frequency => Configuration.dashboard_refresh_interval
-%>
@@ -1,10 +1,10 @@
<h3>Add a new project using the web interface</h3>
-<% form_for :project, :url => projects_path, :action => :post do |p| %>
+<%= form_for :project, :url => projects_path, :action => :post do |p| %>
<dl>
<dt><%= p.label :name, "Name:" %></dt>
<dd><%= p.text_field :name %></dd>
- <% p.fields_for :source_control do |scm| %>
+ <%= p.fields_for :source_control do |scm| %>
<dt><%= scm.label :repository, "Repository path:" %></dt>
<dd><%= scm.text_field :repository %></dd>
View
@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment', __FILE__)
+run CruiseControl::Application
Oops, something went wrong.

0 comments on commit fc94060

Please sign in to comment.