diff --git a/Gemfile.lock b/Gemfile.lock
index 26af276b..cc1b7463 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -41,14 +41,13 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.3.1)
- daemons (1.0.10)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
- gem_plugin (0.2.3)
highline (1.5.2)
hike (1.2.1)
htmlentities (4.3.1)
+ httpclient (2.2.4)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.2)
@@ -60,9 +59,6 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.18)
- mongrel (1.2.0.pre2)
- daemons (~> 1.0.10)
- gem_plugin (~> 0.2.3)
multi_json (1.2.0)
mysql2 (0.3.11)
nokogiri (1.4.7)
@@ -101,7 +97,8 @@ GEM
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
- soap4r-ruby1.9 (2.0.5)
+ soap4r (1.5.8)
+ httpclient (>= 2.1.1)
sprockets (2.1.2)
hike (~> 1.2)
rack (~> 1.0)
@@ -135,13 +132,12 @@ DEPENDENCIES
htmlentities (~> 4.3.0)
jquery-rails
mail
- mongrel (= 1.2.0.pre2)
mysql2
rails (= 3.2.3)
rails_autolink
sanitize (~> 1.2.1)
sass-rails (~> 3.2.3)
- soap4r-ruby1.9
+ soap4r (~> 1.5.8)
sqlite3
swf_fu
uglifier (>= 1.0.3)
diff --git a/app/controllers/data_controller.rb b/app/controllers/data_controller.rb
index 3e87a489..8a530451 100644
--- a/app/controllers/data_controller.rb
+++ b/app/controllers/data_controller.rb
@@ -18,9 +18,9 @@ class DataController < ApplicationController
def yaml_export
all_tables = {}
- all_tables['todos'] = current_user.todos.find(:all, :include => [:tags])
- all_tables['contexts'] = current_user.contexts.find(:all)
- all_tables['projects'] = current_user.projects.find(:all)
+ all_tables['todos'] = current_user.todos.includes(:tags)
+ all_tables['contexts'] = current_user.contexts.all
+ all_tables['projects'] = current_user.projects.all
todo_tag_ids = Tag.find_by_sql([
"SELECT DISTINCT tags.id "+
@@ -34,13 +34,13 @@ class DataController < ApplicationController
"WHERE recurring_todos.user_id=? "+
"AND tags.id = taggings.tag_id " +
"AND taggings.taggable_id = recurring_todos.id ", current_user.id])
- tags = Tag.find(:all, :conditions => ["id IN (?) OR id IN (?)", todo_tag_ids, rec_todo_tag_ids])
- taggings = Tagging.find(:all, :conditions => ["tag_id IN (?) OR tag_id IN(?)", todo_tag_ids, rec_todo_tag_ids])
+ tags = Tag.where("id IN (?) OR id IN (?)", todo_tag_ids, rec_todo_tag_ids)
+ taggings = Tagging.where("tag_id IN (?) OR tag_id IN(?)", todo_tag_ids, rec_todo_tag_ids)
all_tables['tags'] = tags
all_tables['taggings'] = taggings
- all_tables['notes'] = current_user.notes.find(:all)
- all_tables['recurring_todos'] = current_user.recurring_todos.find(:all)
+ all_tables['notes'] = current_user.notes
+ all_tables['recurring_todos'] = current_user.recurring_todos
result = all_tables.to_yaml
result.gsub!(/\n/, "\r\n") # TODO: general functionality for line endings
@@ -53,7 +53,7 @@ class DataController < ApplicationController
csv << ["id", "Context", "Project", "Description", "Notes", "Tags",
"Created at", "Due", "Completed at", "User ID", "Show from",
"state"]
- current_user.todos.find(:all, :include => [:context, :project]).each do |todo|
+ current_user.todos.include(:context, :project).all.each do |todo|
csv << [todo.id, todo.context.name,
todo.project_id.nil? ? "" : todo.project.name,
todo.description,
@@ -78,13 +78,13 @@ class DataController < ApplicationController
# had to remove project include because it's association order is leaking
# through and causing an ambiguous column ref even with_exclusive_scope
# didn't seem to help -JamesKebinger
- current_user.notes.find(:all,:order=>"notes.created_at").each do |note|
+ current_user.notes.order("notes.created_at").each do |note|
# Format dates in ISO format for easy sorting in spreadsheet Print
# context and project names for easy viewing
- csv << [note.id, note.user_id,
+ csv << [note.id, note.user_id,
note.project_id = note.project_id.nil? ? "" : note.project.name,
note.body, note.created_at.to_formatted_s(:db),
- note.updated_at.to_formatted_s(:db)]
+ note.updated_at.to_formatted_s(:db)]
end
end
send_data(result, :filename => "notes.csv", :type => content_type)
@@ -103,17 +103,17 @@ class DataController < ApplicationController
"WHERE recurring_todos.user_id=? "+
"AND tags.id = taggings.tag_id " +
"AND taggings.taggable_id = recurring_todos.id ", current_user.id])
- tags = Tag.find(:all, :conditions => ["id IN (?) OR id IN (?)", todo_tag_ids, rec_todo_tag_ids])
- taggings = Tagging.find(:all, :conditions => ["tag_id IN (?) OR tag_id IN(?)", todo_tag_ids, rec_todo_tag_ids])
+ tags = Tag.where("id IN (?) OR id IN (?)", todo_tag_ids, rec_todo_tag_ids)
+ taggings = Tagging.where("tag_id IN (?) OR tag_id IN(?)", todo_tag_ids, rec_todo_tag_ids)
result = "
Fügen Sie den Inhalt der kopierten YAML Datei in das untenstehende Formular ein:
- <% form_for :import, @import, :url => {:controller => 'data', :action => 'yaml_import'} do |f| %>
+ <%= form_for :import, @import, :url => {:controller => 'data', :action => 'yaml_import'} do |f| %>
<%= f.text_area :yaml %>
<% end %>
diff --git a/app/views/data/yaml_form.en.html.erb b/app/views/data/yaml_form.en.html.erb
index 1b89a9db..c7f04165 100644
--- a/app/views/data/yaml_form.en.html.erb
+++ b/app/views/data/yaml_form.en.html.erb
@@ -1,14 +1,14 @@
Beware: all your current data will be destroyed before importing - the YAML file, so if you have access to the database, we strongly recommend +
Beware: all your current data will be destroyed before importing + the YAML file, so if you have access to the database, we strongly recommend backing up the database right now in case that anything goes wrong.
Paste the contents of the YAML file you exported into the text box below:
- <% form_for :import, @import, :url => {:controller => 'data', :action => 'yaml_import'} do |f| %>
+ <%= form_for :import, @import, :url => {:controller => 'data', :action => 'yaml_import'} do |f| %>
<%= f.text_area :yaml %>
<% end %>
diff --git a/app/views/login/login.html.erb b/app/views/login/login.html.erb
index c22eb6ab..367cbeed 100644
--- a/app/views/login/login.html.erb
+++ b/app/views/login/login.html.erb
@@ -11,21 +11,21 @@
| + |
<% if @username && @user%>
<%= t('login.cas_logged_in_greeting', :username => @username) %> <% elsif @username %> diff --git a/app/views/login/login_mobile.html.erb b/app/views/login/login_mobile.html.erb index 8fb1edfb..afa28de7 100644 --- a/app/views/login/login_mobile.html.erb +++ b/app/views/login/login_mobile.html.erb @@ -11,21 +11,21 @@ <% if show_database_form %>
- <% form_tag login_path(:format => 'm') do %>
+ <%= form_tag login_path(:format => 'm') do %>
<%= error_messages_for(:user) + error_messages_for(:prefs) %>
- <% form_tag :action => 'update' do %>
+ <%= form_tag :action => 'update' do %>
- <% form_for(@new_project, :html => {:id => 'project_form',:name=>'project',:class => "inline-form", :method => :post }) do -%>
+ <%= form_for(@new_project, :html => {:id => 'project_form',:name=>'project',:class => "inline-form", :method => :post }) do -%>
<%= error_messages_for("project") %>
diff --git a/app/views/recurring_todos/_edit_form.html.erb b/app/views/recurring_todos/_edit_form.html.erb index 2f9f6de8..3714e51e 100644 --- a/app/views/recurring_todos/_edit_form.html.erb +++ b/app/views/recurring_todos/_edit_form.html.erb @@ -1,5 +1,5 @@
-<% form_for(@recurring_todo, :html=> { :id=>'recurring-todo-form-edit-action', :name=>'recurring_todo', :class => 'inline-form' }) do |f| -%>
+<%= form_for(@recurring_todo, :html=> { :id=>'recurring-todo-form-edit-action', :name=>'recurring_todo', :class => 'inline-form' }) do |f| -%>
<%= error_messages_for("item", :object_name => 'action') %>
diff --git a/app/views/recurring_todos/_recurring_todo_form.erb b/app/views/recurring_todos/_recurring_todo_form.erb
index 668579a3..86fd9730 100644
--- a/app/views/recurring_todos/_recurring_todo_form.erb
+++ b/app/views/recurring_todos/_recurring_todo_form.erb
@@ -1,6 +1,6 @@
<%- reset_tab_index %>
-<% form_for(@new_recurring_todo, :html=> { :id=>'recurring-todo-form-new-action', :name=>'recurring_todo', :class => 'inline-form' }) do -%>
+<%= form_for(@new_recurring_todo, :html=> { :id=>'recurring-todo-form-new-action', :name=>'recurring_todo', :class => 'inline-form' }) do -%>
<%= error_messages_for("item", :object_name => 'action') %>
diff --git a/app/views/search/index.rhtml b/app/views/search/index.rhtml
index 9573a90b..392720fd 100644
--- a/app/views/search/index.rhtml
+++ b/app/views/search/index.rhtml
@@ -1,5 +1,5 @@
- <% form_tag({:action => :results}, :id => 'search-form') do %>
+ <%= form_tag({:action => :results}, :id => 'search-form') do %>
<%= text_field_tag(:search, params[:search]) %>
<%= submit_tag t('common.search') %>
<% end %>
diff --git a/app/views/todos/edit_mobile.html.erb b/app/views/todos/edit_mobile.html.erb
index 0cf73eb4..22649b90 100644
--- a/app/views/todos/edit_mobile.html.erb
+++ b/app/views/todos/edit_mobile.html.erb
@@ -1,4 +1,4 @@
-<% form_tag todo_path(@todo, :format => 'm'), :name => 'mobileEdit', :method => :put do %>
+<%= form_tag todo_path(@todo, :format => 'm'), :name => 'mobileEdit', :method => :put do %>
<%= render :partial => 'edit_mobile_form', :locals => { :parent_container_type => "show_mobile" } %>
<% end -%>
diff --git a/app/views/todos/new.m.erb b/app/views/todos/new.m.erb
index cf6403a4..e4c3cb07 100644
--- a/app/views/todos/new.m.erb
+++ b/app/views/todos/new.m.erb
@@ -1,4 +1,4 @@
-<% form_tag todos_path(:format => 'm'), :method => :post do %>
+<%= form_tag todos_path(:format => 'm'), :method => :post do %>
<%= render :partial => 'edit_mobile_form' %>
<% end -%>
diff --git a/app/views/users/change_auth_type.html.erb b/app/views/users/change_auth_type.html.erb
index e822bfe8..4d9782fd 100644
--- a/app/views/users/change_auth_type.html.erb
+++ b/app/views/users/change_auth_type.html.erb
@@ -6,7 +6,7 @@
<%= t('users.select_authentication_type') %> - <% form_tag :action => 'update_auth_type' do %> + <%= form_tag :action => 'update_auth_type' do %> <%= select('user', 'auth_type', Tracks::Config.auth_schemes.collect {|p| [ p, p ] }) %>
<%= submit_tag t('users.auth_change_submit') %> <%= link_to t('common.cancel'), preferences_path %>
diff --git a/app/views/users/change_password.html.erb b/app/views/users/change_password.html.erb
index cc3fe546..0f42d4ae 100644
--- a/app/views/users/change_password.html.erb
+++ b/app/views/users/change_password.html.erb
@@ -6,7 +6,7 @@
<%= t('users.change_password_prompt') %> - <% form_tag :action => 'update_password' do %> + <%= form_tag :action => 'update_password' do %> <%= render :partial => 'update_password' %><%= link_to t('common.cancel'), preferences_path %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index d79c6bb3..47e1e783 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -1,5 +1,5 @@
-<% form_tag :action=> "create" do %>
+<%= form_tag :action=> "create" do %>
<%= error_messages_for 'user' %> diff --git a/test/test_helper.rb.rails2 b/backup.rails2.3/test_helper.rb.rails2 similarity index 100% rename from test/test_helper.rb.rails2 rename to backup.rails2.3/test_helper.rb.rails2 diff --git a/test/functional/backend_controller_test.rb b/test/functional/backend_controller_test.rb deleted file mode 100644 index df76e88f..00000000 --- a/test/functional/backend_controller_test.rb +++ /dev/null @@ -1,80 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + '/../test_helper') - -# Re-raise errors caught by the controller. -class BackendController; def rescue_action(e) raise e end; end - -class BackendControllerTest < ActionController::TestCase - fixtures :users, :projects, :contexts, :todos, :recurring_todos, :notes - - def setup - @controller = BackendController.new - request, response = ActionController::TestRequest.new, ActionController::TestResponse.new - assert_equal "change-me", Tracks::Config.salt - end - - def test_new_todo_fails_with_incorrect_token - assert_raises_invalid_token { @controller.new_todo('admin', 'notthecorrecttoken', contexts('agenda').id, 'test', 'test') } - end - - def test_new_todo_fails_with_context_that_does_not_belong_to_user - assert_raise(CannotAccessContext, "Cannot access a context that does not belong to this user.") { @controller.new_todo(users('other_user').login, users('other_user').token, contexts('agenda').id, 'test', 'test') } - end - - def test_new_rich_todo_fails_with_incorrect_token - assert_raises_invalid_token { @controller.new_rich_todo('admin', 'notthecorrecttoken', contexts('agenda').id, 'test', 'test') } - end - - #"Call mfox @call > Build a working time machine" should create the "Call mfox" todo in the 'call' context and the 'Build a working time machine' project. - def test_new_rich_todo_creates_todo_with_exact_match - assert_new_rich_todo_creates_mfox_todo("Call mfox @call > Build a working time machine") - end - - #"Call mfox @cal > Build" should create the "Call mfox" todo in the 'call' context and the 'Build a working time machine' project. - def test_new_rich_todo_creates_todo_with_starts_with_match - assert_new_rich_todo_creates_mfox_todo("Call mfox @cal > Build") - end - - #"Call mfox @call > new:Run for president" should create the 'Run for president' project, create the "Call mfox" todo in the 'call' context and the new project. - def test_new_rich_todo_creates_todo_with_new_project - max_todo_id = Todo.maximum('id') - max_project_id = Project.maximum('id') - @controller.new_rich_todo(users(:admin_user).login, users(:admin_user).token, contexts(:agenda).id, 'Call mfox @call > new:Run for president', 'test') - todo = Todo.find(:first, :conditions => ["id > ?", max_todo_id]) - new_project = Project.find(:first, :conditions => ["id > ?", max_project_id]) - assert_equal(users(:admin_user).id, todo.user_id) - assert_equal(contexts(:call).id, todo.context_id) - assert_equal(new_project.id, todo.project_id) - assert_equal("Call mfox", todo.description) - assert_equal("test", todo.notes) - end - - def assert_new_rich_todo_creates_mfox_todo(description_input) - max_id = Todo.maximum('id') - @controller.new_rich_todo(users(:admin_user).login, users(:admin_user).token, contexts(:agenda).id, 'Call mfox @cal > Build', 'test') - todo = Todo.find(:first, :conditions => ["id > ?", max_id]) - assert_equal(users(:admin_user).id, todo.user_id) - assert_equal(contexts(:call).id, todo.context_id) - assert_equal(projects(:timemachine).id, todo.project_id) - assert_equal('test', todo.notes) - assert_equal("Call mfox", todo.description) - end - - def test_new_rich_todo_fails_with_context_that_does_not_belong_to_user - assert_raise(CannotAccessContext, "Cannot access a context that does not belong to this user.") { @controller.new_rich_todo(users('other_user').login, users('other_user').token, contexts('agenda').id, 'test', 'test') } - end - - def test_list_projects_fails_with_incorrect_token - assert_raises_invalid_token { @controller.list_projects('admin', 'notthecorrecttoken') } - end - - def test_list_contexts_fails_with_incorrect_token - assert_raises_invalid_token { @controller.list_contexts('admin', 'notthecorrecttoken') } - end - - private - - def assert_raises_invalid_token - assert_raise(InvalidToken, "Sorry, you don't have permission to perform this action.") { yield } - end - -end diff --git a/test/functional/stats_controller_test.rb b/test/functional/stats_controller_test.rb old mode 100755 new mode 100644 diff --git a/vendor/plugins/rails_upgrade/MIT-LICENSE b/vendor/plugins/rails_upgrade/MIT-LICENSE deleted file mode 100644 index a7f3e561..00000000 --- a/vendor/plugins/rails_upgrade/MIT-LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2010 Jeremy McAnally - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/rails_upgrade/README.rdoc b/vendor/plugins/rails_upgrade/README.rdoc deleted file mode 100644 index 581d35d7..00000000 --- a/vendor/plugins/rails_upgrade/README.rdoc +++ /dev/null @@ -1,26 +0,0 @@ -= rails-upgrade - -A simple battery of scripts for upgrading Rails app/checking them for required updates. This application should work on Rails 2.x and 3.0, with a focus on upgrading to 3.0. - -== Usage - -You need to install this plugin first: - - script/plugin install git://github.com/rails/rails_upgrade.git - -Then you can run its rake tasks to check your application: - - # Check your app for required upgrades - rake rails:upgrade:check - - # Backup your likely modified files that might be overwritten by the generator - rake rails:upgrade:backup - - # Generate a new route file - rake rails:upgrade:routes - - # Generate a Gemfile from your config.gem directives - rake rails:upgrade:gems - - # Generate code for a new config/application.rb from your environment.rb - rake rails:upgrade:configuration \ No newline at end of file diff --git a/vendor/plugins/rails_upgrade/Rakefile b/vendor/plugins/rails_upgrade/Rakefile deleted file mode 100644 index 421514ed..00000000 --- a/vendor/plugins/rails_upgrade/Rakefile +++ /dev/null @@ -1,22 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -Rake::TestTask.new do |t| - t.libs << 'lib' - t.libs << 'test' - t.test_files = FileList['test/*_test.rb'] - t.verbose = true -end - -desc 'Generate documentation for the rails_upgrade plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Rails-upgrade' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/vendor/plugins/rails_upgrade/init.rb b/vendor/plugins/rails_upgrade/init.rb deleted file mode 100644 index f134b171..00000000 --- a/vendor/plugins/rails_upgrade/init.rb +++ /dev/null @@ -1,2 +0,0 @@ -# Get long stack traces for easier debugging; you'll thank me later. -Rails.backtrace_cleaner.remove_silencers! if Rails.respond_to?(:backtrace_cleaner) diff --git a/vendor/plugins/rails_upgrade/install.rb b/vendor/plugins/rails_upgrade/install.rb deleted file mode 100644 index f064427c..00000000 --- a/vendor/plugins/rails_upgrade/install.rb +++ /dev/null @@ -1,38 +0,0 @@ -puts "Thanks for installing the Rails upgrade plugin. This is a set of generators and analysis tools to help you upgrade your application to Rails 3. It consists of three tasks... - -To get a feel for what you'll need to change to get your app running, run the application analysis: - - rake rails:upgrade:check - -This should give you an idea of the manual changes that need to be done, but you'll probably want to upgrade some of those automatically. The fastest way to do this is to run 'rails .', which will simply generate a new app on top of your existing code. But this generation also has the effect of replacing some existing files, some of which you might not want to replace. To back those up, first run: - - rake rails:upgrade:backup - -That will backup files you've probably edited that will be replaced in the upgrade; if you finish the upgrade and find that you don't need the old copies, just delete them. Otherwise, copy their contents back into the new files or run one of the following upgraders... - -Routes upgrader -=============== - -To generate a new routes file from your existing routes file, simply run the following Rake task: - - rake rails:upgrade:routes - -This will output a new routes file that you can copy and paste or pipe into a new, Rails 3 compatible config/routes.rb. - -Gemfile generator -================= - -Creating a new Gemfile is as simple as running: - - rake rails:upgrade:gems - -This task will extract your config.gem calls and generate code you can put into a bundler compatible Gemfile. - -Configuration generator -======================= - -Much of the configuration information that lived in environment.rb now belongs in a new file named config/application.rb; use the following task to generate code you can put into config/application.rb from your existing config/environment.rb: - - rake rails:upgrade:configuration - -" \ No newline at end of file diff --git a/vendor/plugins/rails_upgrade/lib/application_checker.rb b/vendor/plugins/rails_upgrade/lib/application_checker.rb deleted file mode 100644 index 813890b1..00000000 --- a/vendor/plugins/rails_upgrade/lib/application_checker.rb +++ /dev/null @@ -1,506 +0,0 @@ -require 'open3' - -module Rails - module Upgrading - class ApplicationChecker - def initialize - @issues = [] - - raise NotInRailsAppError unless in_rails_app? - end - - def in_rails_app? - File.exist?("config/environment.rb") - end - - # Run all the check methods - def run - # Ruby 1.8 returns method names as strings whereas 1.9 uses symbols - the_methods = (self.public_methods - Object.methods) - [:run, :initialize, "run", "initialize"] - - the_methods.each {|m| send m } - end - - # Check for deprecated ActiveRecord calls - def check_ar_methods - files = [] - ["find(:all", "find(:first", "find.*:conditions =>", ":joins =>"].each do |v| - lines = grep_for(v, "app/") - files += extract_filenames(lines) || [] - end - - unless files.empty? - alert( - "Soon-to-be-deprecated ActiveRecord calls", - "Methods such as find(:all), find(:first), finds with conditions, and the :joins option will soon be deprecated.", - "http://m.onkey.org/2010/1/22/active-record-query-interface", - files - ) - end - - lines = grep_for("named_scope", "app/models/") - files = extract_filenames(lines) - - unless files.empty? - alert( - "named_scope is now just scope", - "The named_scope method has been renamed to just scope.", - "http://github.com/rails/rails/commit/d60bb0a9e4be2ac0a9de9a69041a4ddc2e0cc914", - files - ) - end - end - - def check_validation_on_methods - files = [] - - ["validate_on_create", "validate_on_update"].each do |v| - lines = grep_for(v, "app/models/") - files += extract_filenames(lines) || [] - end - - unless files.empty? - alert( - "Updated syntax for validate_on_* methods", - "Validate-on-callback methods (validate_on_create/validate_on_destroy) have been changed to validate :x, :on => :create", - "https://rails.lighthouseapp.com/projects/8994/tickets/3880-validate_on_create-and-validate_on_update-no-longer-seem-to-exist", - files - ) - end - end - - def check_before_validation_on_methods - files = [] - - %w(before_validation_on_create before_validation_on_update).each do |v| - lines = grep_for(v, "app/models/") - files += extract_filenames(lines) || [] - end - - unless files.empty? - alert( - "Updated syntax for before_validation_on_* methods", - "before_validation_on_* methods have been changed to before_validation(:on => :create/:update) { ... }", - "https://rails.lighthouseapp.com/projects/8994/tickets/4699-before_validation_on_create-and-before_validation_on_update-doesnt-exist", - files - ) - end - end - - # Check for deprecated router syntax - def check_routes - lines = ["map\\.", "ActionController::Routing::Routes", "\\.resources"].map do |v| - grep_for(v, "config/routes.rb").empty? ? nil : true - end.compact - - unless lines.empty? - alert( - "Old router API", - "The router API has totally changed.", - "http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/", - "config/routes.rb" - ) - end - end - - # Check for deprecated test_help require - def check_test_help - files = [] - - # Hate to duplicate code, but we have to double quote this one... - lines = grep_for("\'test_help\'", "test/", true) - files += extract_filenames(lines) || [] - - lines = grep_for("\"test_help\"", "test/") - files += extract_filenames(lines) || [] - - files.uniq! - - unless files.empty? - alert( - "Deprecated test_help path", - "You now must require 'rails/test_help' not just 'test_help'.", - "http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices", - files - ) - end - end - - # Check for old (pre-application.rb) environment.rb file - def check_environment - unless File.exist?("config/application.rb") - alert( - "New file needed: config/application.rb", - "You need to add a config/application.rb.", - "http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade", - "config/application.rb" - ) - end - - lines = grep_for("config.", "config/environment.rb") - - unless lines.empty? - alert( - "Old environment.rb", - "environment.rb doesn't do what it used to; you'll need to move some of that into application.rb.", - "http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade", - "config/environment.rb" - ) - end - end - - # Check for deprecated constants - def check_deprecated_constants - files = [] - ["RAILS_ENV", "RAILS_ROOT", "RAILS_DEFAULT_LOGGER"].each do |v| - lines = grep_for(v, "app/") - files += extract_filenames(lines) || [] - - lines = grep_for(v, "lib/") - files += extract_filenames(lines) || [] - end - - unless files.empty? - alert( - "Deprecated constant(s)", - "Constants like RAILS_ENV, RAILS_ROOT, and RAILS_DEFAULT_LOGGER are now deprecated.", - "http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/", - files.uniq - ) - end - end - - # Check for old-style config.gem calls - def check_gems - lines = grep_for("config.gem ", "config/*.rb") - lines += grep_for("config.gem ", "config/**/*.rb") - files = extract_filenames(lines) - - unless files.empty? - alert( - "Old gem bundling (config.gems)", - "The old way of bundling is gone now. You need a Gemfile for bundler.", - "http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade", - files - ) - end - end - - # Checks for old mailer syntax in both mailer classes and those - # classes utilizing the mailers - def check_mailers - lines = grep_for("deliver_", "app/models/ #{base_path}app/controllers/ #{base_path}app/observers/") - files = extract_filenames(lines) - - unless files.empty? - alert( - "Deprecated ActionMailer API", - "You're using the old ActionMailer API to send e-mails in a controller, model, or observer.", - "http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3", - files - ) - end - - files = [] - ["recipients ", "attachment(?!s) ", "(?", "app/views/**/*") - lines += grep_for("<% .*javascript_tag.* do.*%>", "app/views/**/*") - lines += grep_for("<% .*form_for.* do.*%>", "app/views/**/*") - lines += grep_for("<% .*form_tag.* do.*%>", "app/views/**/*") - lines += grep_for("<% .*fields_for.* do.*%>", "app/views/**/*") - lines += grep_for("<% .*field_set_tag.* do.*%>", "app/views/**/*") - - files = extract_filenames(lines) - - if !files.blank? - alert( - "Deprecated ERb helper calls", - "Block helpers that use concat (e.g., form_for) should use <%= instead of <%. The current form will continue to work for now, but you will get deprecation warnings since this form will go away in the future.", - "http://weblog.rubyonrails.org/", - files - ) - end - end - - # Checks for old-style AJAX helpers - def check_old_ajax_helpers - files = [] - ['link_to_remote','form_remote_tag','remote_form_for'].each do |type| - lines = grep_for(type, "app/views/**/*") - inner_files = extract_filenames(lines) - files += inner_files unless inner_files.nil? - end - - unless files.empty? - alert( - "Deprecated AJAX helper calls", - "AJAX javascript helpers have been switched to be unobtrusive and use :remote => true instead of having a seperate function to handle remote requests.", - "http://blog.jordanwest.me/modest-rubyist-archive/rails-3-ujs-and-csrf-meta-tags", - files - ) - end - end - - # Checks for old cookie secret settings - def check_old_cookie_secret - lines = grep_for("ActionController::Base.cookie_verifier_secret = ", "config/**/*") - files = extract_filenames(lines) - - unless files.empty? - alert( - "Deprecated cookie secret setting", - "Previously, cookie secret was set directly on ActionController::Base; it's now config.secret_token.", - "http://lindsaar.net/2010/4/7/rails_3_session_secret_and_session_store", - files - ) - end - end - - def check_old_session_secret - lines = grep_for("ActionController::Base.session = {", "config/**/*") - files = extract_filenames(lines) - - unless files.empty? - alert( - "Deprecated session secret setting", - "Previously, session secret was set directly on ActionController::Base; it's now config.secret_token.", - "http://lindsaar.net/2010/4/7/rails_3_session_secret_and_session_store", - files - ) - end - end - - # Checks for old session settings - def check_old_session_setting - lines = grep_for("ActionController::Base.session_store", "config/**/*") - files = extract_filenames(lines) - - unless files.empty? - alert( - "Old session store setting", - "Previously, session store was set directly on ActionController::Base; it's now config.session_store :whatever.", - "http://lindsaar.net/2010/4/7/rails_3_session_secret_and_session_store", - files - ) - end - end - - #Check for old ActionMailer :sent_on attributes - def check_old_action_mailer_sent_on_setting - files = [] - lines = grep_for("sent_on", "app/*") - files += extract_filenames(lines) || [] - - unless files.empty? - alert( - "Deprecated ActionMailer attribute :sent_on", - "Using the new mailer API, you can specify :date to the mail method.", - "http://stackoverflow.com/questions/7367185/weird-error-when-delivering-mail-undefined-method-index-for-2011-09-09-2215", - files - ) - end - end - def check_old_filter_parameter - files = [] - lines = grep_for("filter_parameter_logging", "app/controllers/*") - files += extract_filenames(lines) || [] - - unless files.empty? - alert( - "Deprecated filter_parameter_logging calls", - "The list of filtered parameters are now stored in /config/application.rb. For example: config.filter_parameters += [:password]", - "http://de.asciicasts.com/episodes/224-controller-in-rails-3", - files - ) - end - end - private - def grep_for_with_perl_regex(text, where = "./", double_quote = false) - grep_for(text, where, double_quote, true) - end - - # Find a string in a set of files; calls +find_with_grep+ and +find_with_rak+ - # depending on platform. - # - # TODO: Figure out if this works on Windows. - def grep_for(text, where = "./", double_quote = false, perl_regex = false) - # If they're on Windows, they probably don't have grep. - @probably_has_grep ||= (Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/).nil? - - # protect against double root paths in Rails 3 - where.gsub!(Regexp.new(base_path),'') - - lines = if @probably_has_grep - find_with_grep(text, base_path + where, double_quote, perl_regex) - else - find_with_rak(text, base_path + where, double_quote) - end - - # ignore comments - lines.gsub /^(\/[^:]+:)?\s*#.+$/m, "" - end - - # Sets a base path for finding files; mostly for testing - def base_path - Dir.pwd + "/" - end - - # Use the grep utility to find a string in a set of files - def find_with_grep(text, where, double_quote, perl_regex = false) - value = "" - # Specifically double quote for finding 'test_help' - command = if double_quote - "grep -rH #{"-P" if perl_regex} \"#{text}\" #{where} | grep -v \.svn" - else - "grep -rH #{"-P" if perl_regex} '#{text}' #{where} | grep -v \.svn" - end - - Open3.popen3(command) do |stdin, stdout, stderr| - value = stdout.read - end - value - end - - # Use the rak gem to grep the files (not yet implemented) - def find_with_rak(text, where, double_quote) - value = "" - Open3.popen3("rak --nogroup -l '#{Regexp.escape(text)}' #{where}") do |stdin, stdout, stderr| - value = stdout.read - end - value - end - - # Extract the filenames from the grep output - def extract_filenames(output) - if @probably_has_grep - filenames = extract_filenames_from_grep(output) - else - filenames = extract_filenames_from_rak(output) - end - - filenames.compact.map do |f| - f.gsub(base_path, "") - end - end - - def extract_filenames_from_grep(output) - return [] if output.empty? - - output.split("\n").map do |fn| - if m = fn.match(/^(.+?):/) - m[1] - end - end.compact.uniq - end - - def extract_filenames_from_rak(output) - return [] if output.empty? - - output.split("\n").uniq - end - - # Terminal colors, borrowed from Thor - CLEAR = "\e[0m" - BOLD = "\e[1m" - RED = "\e[31m" - YELLOW = "\e[33m" - CYAN = "\e[36m" - WHITE = "\e[37m" - - # Show an upgrade alert to the user - def alert(title, text, more_info_url, culprits) - if Config::CONFIG['host_os'].downcase =~ /mswin|windows|mingw/ - basic_alert(title, text, more_info_url, culprits) - else - color_alert(title, text, more_info_url, culprits) - end - end - - # Show an upgrade alert to the user. If we're on Windows, we can't - # use terminal colors, hence this method. - def basic_alert(title, text, more_info_url, culprits) - puts "** " + title - puts text - puts "More information: #{more_info_url}" - puts - puts "The culprits: " - Array(culprits).each do |c| - puts "\t- #{c}" - end - puts - end - - # Show a colorful alert to the user - def color_alert(title, text, more_info_url, culprits) - puts "#{RED}#{BOLD}#{title}#{CLEAR}" - puts "#{WHITE}#{text}" - puts "#{BOLD}More information:#{CLEAR} #{CYAN}#{more_info_url}" - puts - puts "#{WHITE}The culprits: " - Array(culprits).each do |c| - puts "#{YELLOW}\t- #{c}" - end - ensure - puts "#{CLEAR}" - end - end - end -end diff --git a/vendor/plugins/rails_upgrade/lib/gemfile_generator.rb b/vendor/plugins/rails_upgrade/lib/gemfile_generator.rb deleted file mode 100644 index b2a2b204..00000000 --- a/vendor/plugins/rails_upgrade/lib/gemfile_generator.rb +++ /dev/null @@ -1,95 +0,0 @@ -module Rails - module Upgrading - class GemfileGenerator - def generate_new_gemfile - if has_environment? - generate_gemfile - else - raise FileNotFoundError, "Can't find environment.rb [config/environment.rb]!" - end - end - - def has_environment? - File.exists?("config/environment.rb") - end - - def environment_code - File.open("config/environment.rb").read - end - - def generate_gemfile - environment_file = environment_code - - # Get each line that starts with config.gem - gem_lines = environment_file.split("\n").select {|l| l =~ /^\s*config\.gem/} - - # Toss those lines to a generator class; the lines are evaluated in the - # context of that instance. - config = GemfileGenerator.new - config.instance_eval(gem_lines.join("\n")) - - config.output - end - end - - class GemfileGenerator - # Creates a target for the config.gem calls - def config - self - end - - def initialize - @gems = [] - end - - # Receive a call to add a gem to the list - def gem(name, options={}) - data = {} - - # Add new keys from old keys - data[:require] = options[:lib] if options[:lib] - data[:source] = options[:source] if options[:source] - - version = options[:version] - @gems << [name, version, data] - end - - # Generate the Gemfile output - def output - # Generic preamble, taken from Yehuda Katz's blog - preamble = < |