Merge pull request #1910 from dnrce/rails42

Upgrade to Rails 4.2
This commit is contained in:
Matt Rogers 2016-06-14 19:27:18 -05:00 committed by GitHub
commit 7748253388
41 changed files with 378 additions and 274 deletions

13
Gemfile
View file

@ -1,8 +1,8 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'rails', '~>4.1.11' gem 'rails', '~> 4.2.6'
gem 'sass-rails', '~>4.0' gem 'sass-rails', '~> 5.0'
gem 'coffee-rails', '~>4.0' gem 'coffee-rails', '~> 4.1.0'
#gem 'json' #gem 'json'
@ -52,7 +52,7 @@ group :development do
gem "spring-commands-cucumber" gem "spring-commands-cucumber"
gem "yard" gem "yard"
gem 'tolk', '~> 1.6.0' gem 'tolk', '~> 1.9.3'
gem "bullet" gem "bullet"
gem "rack-mini-profiler" gem "rack-mini-profiler"
@ -65,12 +65,17 @@ group :development, :test do
end end
group :test do group :test do
# Pull in the fix for rails-dom-testing issue #42
# TODO: Remove with Rails 5 and rails-dom-testing 2.x
gem 'rails-dom-testing', github: 'rails/rails-dom-testing', ref: 'a64f30514ee65f172c43f42cfd4500b5e11a561a'
gem "factory_girl_rails" gem "factory_girl_rails"
gem "capybara" gem "capybara"
gem "cucumber-rails", :require => false gem "cucumber-rails", :require => false
gem "rspec-expectations" gem "rspec-expectations"
gem "database_cleaner" gem "database_cleaner"
gem "mocha", :require => false gem "mocha", :require => false
gem "minitest-stub-const"
gem "aruba", ">=0.5.4", :require => false gem "aruba", ">=0.5.4", :require => false

View file

@ -1,40 +1,59 @@
GIT
remote: git://github.com/rails/rails-dom-testing.git
revision: a64f30514ee65f172c43f42cfd4500b5e11a561a
ref: a64f30514ee65f172c43f42cfd4500b5e11a561a
specs:
rails-dom-testing (1.0.7)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
RedCloth (4.2.9) RedCloth (4.2.9)
aasm (3.4.0) aasm (3.4.0)
actionmailer (4.1.14.1) actionmailer (4.2.6)
actionpack (= 4.1.14.1) actionpack (= 4.2.6)
actionview (= 4.1.14.1) actionview (= 4.2.6)
activejob (= 4.2.6)
mail (~> 2.5, >= 2.5.4) mail (~> 2.5, >= 2.5.4)
actionpack (4.1.14.1) rails-dom-testing (~> 1.0, >= 1.0.5)
actionview (= 4.1.14.1) actionpack (4.2.6)
activesupport (= 4.1.14.1) actionview (= 4.2.6)
rack (~> 1.5.2) activesupport (= 4.2.6)
rack (~> 1.6)
rack-test (~> 0.6.2) rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-xml_parser (1.0.1) actionpack-xml_parser (1.0.1)
actionpack (>= 4.0.0.rc1) actionpack (>= 4.0.0.rc1)
actionview (4.1.14.1) actionview (4.2.6)
activesupport (= 4.1.14.1) activesupport (= 4.2.6)
builder (~> 3.1) builder (~> 3.1)
erubis (~> 2.7.0) erubis (~> 2.7.0)
activemodel (4.1.14.1) rails-dom-testing (~> 1.0, >= 1.0.5)
activesupport (= 4.1.14.1) rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.6)
activesupport (= 4.2.6)
globalid (>= 0.3.0)
activemodel (4.2.6)
activesupport (= 4.2.6)
builder (~> 3.1) builder (~> 3.1)
activerecord (4.1.14.1) activerecord (4.2.6)
activemodel (= 4.1.14.1) activemodel (= 4.2.6)
activesupport (= 4.1.14.1) activesupport (= 4.2.6)
arel (~> 5.0.0) arel (~> 6.0)
activerecord-deprecated_finders (1.0.3) activerecord-deprecated_finders (1.0.3)
activesupport (4.1.14.1) activesupport (4.2.6)
i18n (~> 0.6, >= 0.6.9) i18n (~> 0.7)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.1) thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
acts_as_list (0.5.0) acts_as_list (0.7.2)
activerecord (>= 3.0) activerecord (>= 3.0)
arel (5.0.1.20140414130214) arel (6.0.3)
aruba (0.6.1) aruba (0.6.1)
childprocess (>= 0.3.6) childprocess (>= 0.3.6)
cucumber (>= 1.1.1) cucumber (>= 1.1.1)
@ -68,10 +87,11 @@ GEM
coffee-rails (4.1.0) coffee-rails (4.1.0)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
coffee-script (2.3.0) coffee-script (2.4.1)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.8.0) coffee-script-source (1.9.1.1)
concurrent-ruby (1.0.2)
crass (0.2.1) crass (0.2.1)
cucumber (1.3.18) cucumber (1.3.18)
builder (>= 2.1.2) builder (>= 2.1.2)
@ -102,7 +122,8 @@ GEM
sass (>= 3.2) sass (>= 3.2)
gherkin (2.12.2) gherkin (2.12.2)
multi_json (~> 1.3) multi_json (~> 1.3)
hike (1.2.3) globalid (0.3.6)
activesupport (>= 4.1.0)
htmlentities (4.3.3) htmlentities (4.3.3)
i18n (0.7.0) i18n (0.7.0)
jquery-rails (3.1.3) jquery-rails (3.1.3)
@ -112,20 +133,23 @@ GEM
railties (>= 3.2.16) railties (>= 3.2.16)
json (1.8.3) json (1.8.3)
libv8 (3.16.14.7) libv8 (3.16.14.7)
mail (2.6.3) loofah (2.0.3)
mime-types (>= 1.16, < 3) nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
metaclass (0.0.4) metaclass (0.0.4)
method_source (0.8.2) method_source (0.8.2)
mime-types (2.99) mime-types (2.99.2)
mimemagic (0.3.0) mimemagic (0.3.0)
mini_portile2 (2.0.0) mini_portile2 (2.0.0)
minitest (5.8.4) minitest (5.9.0)
minitest-stub-const (0.5)
mocha (1.1.0) mocha (1.1.0)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
multi_json (1.11.2) multi_json (1.11.2)
multi_test (0.1.1) multi_test (0.1.1)
mysql2 (0.3.20) mysql2 (0.3.20)
nokogiri (1.6.7) nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2) mini_portile2 (~> 2.0.0.rc2)
nokogumbo (1.1.12) nokogumbo (1.1.12)
nokogiri nokogiri
@ -139,31 +163,36 @@ GEM
coderay (~> 1.1.0) coderay (~> 1.1.0)
method_source (~> 0.8.1) method_source (~> 0.8.1)
slop (~> 3.4) slop (~> 3.4)
rack (1.5.5) rack (1.6.4)
rack-dev-mark (0.7.3) rack-dev-mark (0.7.3)
rack (>= 1.1) rack (>= 1.1)
rack-mini-profiler (0.9.2) rack-mini-profiler (0.9.2)
rack (>= 1.1.3) rack (>= 1.1.3)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rails (4.1.14.1) rails (4.2.6)
actionmailer (= 4.1.14.1) actionmailer (= 4.2.6)
actionpack (= 4.1.14.1) actionpack (= 4.2.6)
actionview (= 4.1.14.1) actionview (= 4.2.6)
activemodel (= 4.1.14.1) activejob (= 4.2.6)
activerecord (= 4.1.14.1) activemodel (= 4.2.6)
activesupport (= 4.1.14.1) activerecord (= 4.2.6)
activesupport (= 4.2.6)
bundler (>= 1.3.0, < 2.0) bundler (>= 1.3.0, < 2.0)
railties (= 4.1.14.1) railties (= 4.2.6)
sprockets-rails (~> 2.0) sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails_autolink (1.1.6) rails_autolink (1.1.6)
rails (> 3.1) rails (> 3.1)
railties (4.1.14.1) railties (4.2.6)
actionpack (= 4.1.14.1) actionpack (= 4.2.6)
activesupport (= 4.1.14.1) activesupport (= 4.2.6)
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (10.5.0) rake (11.1.2)
ref (1.0.5) ref (1.0.5)
rspec-expectations (3.1.2) rspec-expectations (3.1.2)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
@ -175,12 +204,13 @@ GEM
crass (~> 0.2.0) crass (~> 0.2.0)
nokogiri (>= 1.4.4) nokogiri (>= 1.4.4)
nokogumbo (= 1.1.12) nokogumbo (= 1.1.12)
sass (3.2.19) sass (3.4.22)
sass-rails (4.0.4) sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0) railties (>= 4.0.0, < 5.0)
sass (~> 3.2.2) sass (~> 3.1)
sprockets (~> 2.8, < 2.12) sprockets (>= 2.8, < 4.0)
sprockets-rails (~> 2.0) sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (2.50.0) selenium-webdriver (2.50.0)
childprocess (~> 0.5) childprocess (~> 0.5)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -195,15 +225,13 @@ GEM
spring (1.1.3) spring (1.1.3)
spring-commands-cucumber (1.0.1) spring-commands-cucumber (1.0.1)
spring (>= 0.9.1) spring (>= 0.9.1)
sprockets (2.11.3) sprockets (3.6.0)
hike (~> 1.2) concurrent-ruby (~> 1.0)
multi_json (~> 1.0) rack (> 1, < 3)
rack (~> 1.0) sprockets-rails (3.0.4)
tilt (~> 1.1, != 1.3.0) actionpack (>= 4.0)
sprockets-rails (2.3.3) activesupport (>= 4.0)
actionpack (>= 3.0) sprockets (>= 3.0.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10) sqlite3 (1.3.10)
swf_fu (2.0.4) swf_fu (2.0.4)
coffee-script coffee-script
@ -217,11 +245,10 @@ GEM
rack (~> 1.0) rack (~> 1.0)
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (2.0.4)
tolk (1.6.0) tolk (1.9.3)
rails (>= 4.0, < 4.2) rails (>= 4.0, < 4.3)
safe_yaml (>= 0.8.6) safe_yaml (>= 0.8.6)
will_paginate
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uglifier (2.7.2) uglifier (2.7.2)
@ -249,7 +276,7 @@ DEPENDENCIES
bullet bullet
capybara capybara
codeclimate-test-reporter codeclimate-test-reporter
coffee-rails (~> 4.0) coffee-rails (~> 4.1.0)
cucumber-rails cucumber-rails
database_cleaner database_cleaner
factory_girl_rails factory_girl_rails
@ -257,17 +284,19 @@ DEPENDENCIES
htmlentities htmlentities
jquery-rails jquery-rails
jquery-ui-rails jquery-ui-rails
minitest-stub-const
mocha mocha
mysql2 (~> 0.3.17) mysql2 (~> 0.3.17)
paperclip paperclip
pry pry
rack-dev-mark rack-dev-mark
rack-mini-profiler rack-mini-profiler
rails (~> 4.1.11) rails (~> 4.2.6)
rails-dom-testing!
rails_autolink rails_autolink
rspec-expectations rspec-expectations
sanitize (>= 3.0.0) sanitize (>= 3.0.0)
sass-rails (~> 4.0) sass-rails (~> 5.0)
selenium-webdriver (>= 2.50) selenium-webdriver (>= 2.50)
simplecov simplecov
spring spring
@ -276,10 +305,10 @@ DEPENDENCIES
swf_fu swf_fu
therubyracer therubyracer
thin thin
tolk (~> 1.6.0) tolk (~> 1.9.3)
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
will_paginate will_paginate
yard yard
BUNDLED WITH BUNDLED WITH
1.10.6 1.11.2

View file

@ -2,7 +2,7 @@
// listed below. // listed below.
// //
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
// //
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. // compiled file.

View file

@ -3,7 +3,7 @@
* listed below. * listed below.
* *
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
* *
* You're free to add application-wide styles to this file and they'll appear at the bottom of the * You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles * compiled file so the styles you add here take precedence over styles defined in any styles

3
bin/bundle Executable file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')

View file

@ -1,10 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin APP_PATH = File.expand_path('../../config/application', __FILE__)
load File.expand_path("../spring", __FILE__) require_relative '../config/boot'
rescue LoadError
end
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands' require 'rails/commands'

View file

@ -1,7 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
begin require_relative '../config/boot'
load File.expand_path("../spring", __FILE__) require 'rake'
rescue LoadError Rake.application.run
end
require 'bundler/setup'
load Gem.bin_path('rake', 'rake')

29
bin/setup Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end

View file

@ -28,12 +28,12 @@ module Tracksapp
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de # config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
# configure Tracks to handle deployment in a subdir # configure Tracks to handle deployment in a subdir
config.relative_url_root = SITE_CONFIG['subdir'] if SITE_CONFIG['subdir'] config.relative_url_root = SITE_CONFIG['subdir'] if SITE_CONFIG['subdir']
# allow onenote:// and message:// as protocols for urls
config.action_view.sanitized_allowed_protocols = 'onenote', 'message'
config.middleware.insert_after ActionDispatch::ParamsParser, ActionDispatch::XmlParamsParser config.middleware.insert_after ActionDispatch::ParamsParser, ActionDispatch::XmlParamsParser
end end
end end

View file

@ -1,4 +1,3 @@
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) require 'bundler/setup' # Set up gems listed in the Gemfile.

View file

@ -27,6 +27,10 @@ Rails.application.configure do
# number of complex assets. # number of complex assets.
config.assets.debug = true config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime. # Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies. # Checks for improperly declared sprockets dependencies.
# Raises helpful error messages. # Raises helpful error messages.

View file

@ -16,11 +16,13 @@ Rails.application.configure do
# Enable Rack::Cache to put a simple HTTP cache in front of your application # Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this. # Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. # For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true # config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this). # Disable serving static files from the `/public` folder by default since
config.serve_static_assets = SITE_CONFIG['serve_static_assets'] || false # Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? || SITE_CONFIG['serve_static_assets'] || false
# Compress JavaScripts and CSS. # Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier config.assets.js_compressor = :uglifier
@ -29,20 +31,22 @@ Rails.application.configure do
# Do not fallback to assets pipeline if a precompiled asset is missed. # Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false config.assets.compile = false
# Generate digests for assets URLs. # Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files. # Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true # config.force_ssl = true
# Set to :debug to see everything in the log. # Use the lowest log level to ensure availability of diagnostic information
config.log_level = :info # when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags. # Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ] # config.log_tags = [ :subdomain, :uuid ]
@ -54,7 +58,7 @@ Rails.application.configure do
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server. # Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com" # config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors. # Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors.
@ -67,9 +71,6 @@ Rails.application.configure do
# Send deprecation notices to registered listeners. # Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed. # Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new config.log_formatter = ::Logger::Formatter.new

View file

@ -12,8 +12,8 @@ Rails.application.configure do
# preloads Rails for running tests, you may have to set it to true. # preloads Rails for running tests, you may have to set it to true.
config.eager_load = false config.eager_load = false
# Configure static asset server for tests with Cache-Control for performance. # Configure static file server for tests with Cache-Control for performance.
config.serve_static_assets = true config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600' config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching. # Show full error reports and disable caching.
@ -31,6 +31,9 @@ Rails.application.configure do
# ActionMailer::Base.deliveries array. # ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test config.action_mailer.delivery_method = :test
# Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr. # Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr config.active_support.deprecation = :stderr

View file

@ -3,6 +3,9 @@
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0' Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets. # Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( print.css mobile.css jquery-ui/datepicker-*.js ) Rails.application.config.assets.precompile += %w( print.css mobile.css jquery-ui/datepicker-*.js )

View file

@ -0,0 +1,3 @@
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :marshal

View file

@ -2,7 +2,6 @@
# Add new mime types for use in respond_to blocks: # Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf # Mime::Type.register "text/richtext", :rtf
# Mime::Type.register_alias "text/html", :iphone
Mime::Type.register_alias "text/html", :m Mime::Type.register_alias "text/html", :m
Mime::Type.register_alias "text/plain", :autocomplete Mime::Type.register_alias "text/plain", :autocomplete

View file

@ -0,0 +1 @@
Loofah::HTML5::WhiteList::ALLOWED_PROTOCOLS.merge(%w(message onenote))

View file

@ -2,6 +2,7 @@
* Removed support for deprecated password-hashing algorithm. This * Removed support for deprecated password-hashing algorithm. This
eliminates config.salt. Note the addition of a pre-upgrade step to eliminates config.salt. Note the addition of a pre-upgrade step to
check for obsolete passwords. check for obsolete passwords.
* Rails 4.2
* Thin replaces WEBrick as the included web server * Thin replaces WEBrick as the included web server
* Tracks is tested on Ruby 1.9.3, 2.0.0, 2.1, and 2.2. * Tracks is tested on Ruby 1.9.3, 2.0.0, 2.1, and 2.2.
* The MessageGateway will save the received email as an attachement to the todo * The MessageGateway will save the received email as an attachement to the todo

View file

@ -94,11 +94,11 @@ While still in the Terminal inside the Tracks root directory, issue the followin
bundle exec rails server -e production bundle exec rails server -e production
If all goes well, you should see some text informing you that the server is running: `=> Rails application starting in production on http://0.0.0.0:3000`. If you are already running other services on port 3000, you need to select a different port when running the server, using the `-p` option. If all goes well, you should see some text informing you that the server is running: `=> Rails application starting in production on http://localhost:3000`. If you are already running other services on port 3000, you need to select a different port when running the server, using the `-p` option.
## Visit Tracks in a browser ## Visit Tracks in a browser
Visit `http://0.0.0.0:3000/signup` in a browser (or whatever URL and port was reported when you started the server in the step above) and chose a user name and password for admin user. Once logged in as admin, you can add other (ordinary level) users. If you need to access Tracks from a mobile/cellular phone browser, visit `http://yourdomain.com/mobile/`. This mobile version is a special, lightweight version of Tracks, designed to use on a mobile browser. Visit `http://localhost:3000/signup` in a browser (or whatever URL and port was reported when you started the server in the step above) and chose a user name and password for admin user. Once logged in as admin, you can add other (ordinary level) users. If you need to access Tracks from a mobile/cellular phone browser, visit `http://yourdomain.com/mobile/`. This mobile version is a special, lightweight version of Tracks, designed to use on a mobile browser.
## Customise Tracks ## Customise Tracks

View file

@ -37,7 +37,7 @@ require 'activeresource'
module Tracks module Tracks
class Base < ActiveResource::Base class Base < ActiveResource::Base
self.site = ENV["SITE"] || "http://username:password@0.0.0.0:3000/" self.site = ENV["SITE"] || "http://username:password@localhost:3000/"
end end
class Todo < Base class Todo < Base
@ -57,4 +57,4 @@ module Tracks
end end
end end
end end

View file

@ -5,7 +5,7 @@ namespace :ci do
puts 'Running "lite" test suite' puts 'Running "lite" test suite'
[:environment, 'db:create', 'test:all'].each do |t| [:environment, 'db:create', :test].each do |t|
Rake::Task[t].invoke Rake::Task[t].invoke
end end
end end

View file

@ -1,6 +1,9 @@
require 'test_helper' require 'test_helper'
require 'support/html_entity_helper'
class ContextsControllerTest < ActionController::TestCase class ContextsControllerTest < ActionController::TestCase
include HTMLEntityHelper
fixtures :users, :preferences, :contexts fixtures :users, :preferences, :contexts
def test_contexts_list def test_contexts_list
@ -96,7 +99,7 @@ class ContextsControllerTest < ActionController::TestCase
login_as :admin_user login_as :admin_user
get :show, { :id => "0", :format => 'xml' } get :show, { :id => "0", :format => 'xml' }
assert_response 404 assert_response 404
assert_xml_select 'error', 'Context not found' assert_select 'error', 'Context not found'
end end
# RSS # RSS
@ -107,7 +110,7 @@ class ContextsControllerTest < ActionController::TestCase
assert_equal 'application/rss+xml', @response.content_type assert_equal 'application/rss+xml', @response.content_type
#puts @response.body #puts @response.body
assert_xml_select 'rss[version="2.0"]' do assert_select 'rss[version="2.0"]' do
assert_select 'channel' do assert_select 'channel' do
assert_select '>title', 'Tracks Contexts' assert_select '>title', 'Tracks Contexts'
assert_select '>description', "Lists all the contexts for #{users(:admin_user).display_name}" assert_select '>description', "Lists all the contexts for #{users(:admin_user).display_name}"
@ -118,7 +121,7 @@ class ContextsControllerTest < ActionController::TestCase
assert_select 'title', /.+/ assert_select 'title', /.+/
assert_select 'description' do assert_select 'description' do
assert_select_encoded do assert_select_encoded do
assert_select 'p', /\d+&nbsp;actions. Context is (Active|Hidden)./ assert_select 'p', /\d+#{nbsp}actions. Context is (Active|Hidden)./
end end
end end
%w(guid link).each do |node| %w(guid link).each do |node|
@ -153,16 +156,15 @@ class ContextsControllerTest < ActionController::TestCase
login_as :admin_user login_as :admin_user
get :index, { :format => "atom" } get :index, { :format => "atom" }
assert_equal 'application/atom+xml', @response.content_type assert_equal 'application/atom+xml', @response.content_type
#puts @response.body assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
assert_select 'feed' do
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do
assert_select '>title', 'Tracks Contexts' assert_select '>title', 'Tracks Contexts'
assert_select '>subtitle', "Lists all the contexts for #{users(:admin_user).display_name}" assert_select '>subtitle', "Lists all the contexts for #{users(:admin_user).display_name}"
assert_select 'entry', 10 do assert_select 'entry', 10 do
assert_select 'title', /.+/ assert_select 'title', /.+/
assert_select 'content[type="html"]' do assert_select 'content[type="html"]' do
assert_select_encoded do assert_select_encoded do
assert_select 'p', /\d+&nbsp;actions. Context is (Active|Hidden)./ assert_select 'p', /\d+#{nbsp}actions. Context is (Active|Hidden)./
end end
end end
assert_select 'published', /(#{Regexp.escape(contexts(:agenda).created_at.xmlschema)}|#{Regexp.escape(contexts(:library).created_at.xmlschema)})/ assert_select 'published', /(#{Regexp.escape(contexts(:agenda).created_at.xmlschema)}|#{Regexp.escape(contexts(:library).created_at.xmlschema)})/

View file

@ -26,4 +26,4 @@ class FeedlistControllerTest < ActionController::TestCase
assert_response 200 assert_response 200
end end
end end

View file

@ -1,6 +1,8 @@
require 'test_helper' require 'test_helper'
require 'support/stub_site_config_helper'
class IntegrationsControllerTest < ActionController::TestCase class IntegrationsControllerTest < ActionController::TestCase
include StubSiteConfigHelper
def setup def setup
end end
@ -12,58 +14,64 @@ class IntegrationsControllerTest < ActionController::TestCase
end end
def test_cloudmailin_integration_success def test_cloudmailin_integration_success
SITE_CONFIG['cloudmailin'] = "123456789" stub_site_config do
SITE_CONFIG['email_dispatch'] = 'from' SITE_CONFIG['cloudmailin'] = "123456789"
post :cloudmailin, { SITE_CONFIG['email_dispatch'] = 'from'
"html"=>"", post :cloudmailin, {
"plain"=>"asdasd", "html"=>"",
"x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]", "plain"=>"asdasd",
"disposable"=>"", "x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]",
"from"=>"5555555555@tmomail.net", "disposable"=>"",
"signature"=>"e85e908fb893394762047c21e54ce248", "from"=>"5555555555@tmomail.net",
"to"=>"<123123@cloudmailin.net>", "signature"=>"e85e908fb893394762047c21e54ce248",
"subject"=>"asd", "to"=>"<123123@cloudmailin.net>",
"x_cc_header"=>"", "subject"=>"asd",
"message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n" "x_cc_header"=>"",
} "message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n"
}
assert_response :success
assert_response :success
end
end end
def test_cloudmailin_integration_invalid_signature def test_cloudmailin_integration_invalid_signature
SITE_CONFIG['cloudmailin'] = "12345678901234567890" stub_site_config do
post :cloudmailin, { SITE_CONFIG['cloudmailin'] = "12345678901234567890"
"html"=>"", post :cloudmailin, {
"plain"=>"asdasd", "html"=>"",
"x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]", "plain"=>"asdasd",
"disposable"=>"", "x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]",
"from"=>"5555555555@tmomail.net", "disposable"=>"",
"signature"=>"e85e908fb893394762047c21e54ce248", "from"=>"5555555555@tmomail.net",
"to"=>"<123123@cloudmailin.net>", "signature"=>"e85e908fb893394762047c21e54ce248",
"subject"=>"asd", "to"=>"<123123@cloudmailin.net>",
"x_cc_header"=>"", "subject"=>"asd",
"message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n" "x_cc_header"=>"",
} "message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <5555555555@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n"
}
assert_response 403
assert_response 403
end
end end
def test_cloudmailin_integration_unknown_address def test_cloudmailin_integration_unknown_address
SITE_CONFIG['cloudmailin'] = "123456789" stub_site_config do
post :cloudmailin, { SITE_CONFIG['cloudmailin'] = "123456789"
"html"=>"", post :cloudmailin, {
"plain"=>"asdasd", "html"=>"",
"x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]", "plain"=>"asdasd",
"disposable"=>"", "x_to_header"=>"[\"81496ecea21032d35a7a@cloudmailin.net\"]",
"from"=>"444444444444@tmomail.net", "disposable"=>"",
"signature"=>"6d2df0e807bfa9b77d24c31dce6d4515", "from"=>"444444444444@tmomail.net",
"to"=>"<123123@cloudmailin.net>", "signature"=>"6d2df0e807bfa9b77d24c31dce6d4515",
"subject"=>"asd", "to"=>"<123123@cloudmailin.net>",
"x_cc_header"=>"", "subject"=>"asd",
"message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <444444444444@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n" "x_cc_header"=>"",
} "message"=>"Received: from VMBX103.ihostexchange.net ([192.168.3.3]) by\r\n HUB103.ihostexchange.net ([66.46.182.53]) with mapi; Wed, 5 Oct 2011 17:12:44\r\n -0400\r\nFrom: SMS User <444444444444@tmomail.net>\r\nTo: Tracks <123123@cloudmailin.net>\r\nDate: Wed, 5 Oct 2011 17:12:43 -0400\r\nSubject: asd\r\nThread-Topic: asd\r\nThread-Index: AcyDo4aig2wghvcsTAOkleWqi4t/FQ==\r\nMessage-ID: <7D7CB176-7559-4997-A301-8DF9726264C7@tmomail.net>\r\nAccept-Language: de-DE, en-US\r\nContent-Language: en-US\r\nX-MS-Has-Attach:\r\nX-MS-TNEF-Correlator:\r\nacceptlanguage: de-DE, en-US\r\nContent-Type: text/plain; charset=\"us-ascii\"\r\nContent-Transfer-Encoding: quoted-printable\r\nMIME-Version: 1.0\r\n\r\nasdasd\r\n"
}
assert_response 404
assert_response 404
end
end end
end end

View file

@ -1,6 +1,8 @@
require 'test_helper' require 'test_helper'
require 'support/stub_site_config_helper'
class MailgunControllerTest < ActionController::TestCase class MailgunControllerTest < ActionController::TestCase
include StubSiteConfigHelper
def setup def setup
@user = users(:sms_user) @user = users(:sms_user)
@ -12,55 +14,61 @@ class MailgunControllerTest < ActionController::TestCase
end end
def test_mailgun_signature_verifies def test_mailgun_signature_verifies
SITE_CONFIG['mailgun_api_key'] = "123456789" stub_site_config do
SITE_CONFIG['email_dispatch'] = 'from' SITE_CONFIG['mailgun_api_key'] = "123456789"
SITE_CONFIG['email_dispatch'] = 'from'
post :mailgun, { post :mailgun, {
"timestamp" => "1379539674", "timestamp" => "1379539674",
"token" => "5km6cwo0e3bfvg78hw4s69znro09xhk1h8u6-s633yasc8hcr5", "token" => "5km6cwo0e3bfvg78hw4s69znro09xhk1h8u6-s633yasc8hcr5",
"signature" => "da92708b8f2c9dcd7ecdc91d52946c01802833e6683e46fc00b3f081920dd5b1", "signature" => "da92708b8f2c9dcd7ecdc91d52946c01802833e6683e46fc00b3f081920dd5b1",
"body-mime" => load_message('mailgun_message1.txt') "body-mime" => load_message('mailgun_message1.txt')
} }
assert_response :success assert_response :success
end
end end
def test_mailgun_creates_todo_with_mailmap def test_mailgun_creates_todo_with_mailmap
SITE_CONFIG['mailgun_api_key'] = "123456789" stub_site_config do
SITE_CONFIG['email_dispatch'] = 'to' SITE_CONFIG['mailgun_api_key'] = "123456789"
SITE_CONFIG['mailmap'] = { SITE_CONFIG['email_dispatch'] = 'to'
'5555555555@tmomail.net' => ['incoming@othermail.com', 'notused@foo.org'] SITE_CONFIG['mailmap'] = {
} '5555555555@tmomail.net' => ['incoming@othermail.com', 'notused@foo.org']
}
todo_count = Todo.count todo_count = Todo.count
post :mailgun, { post :mailgun, {
"timestamp" => "1379539674", "timestamp" => "1379539674",
"token" => "5km6cwo0e3bfvg78hw4s69znro09xhk1h8u6-s633yasc8hcr5", "token" => "5km6cwo0e3bfvg78hw4s69znro09xhk1h8u6-s633yasc8hcr5",
"signature" => "da92708b8f2c9dcd7ecdc91d52946c01802833e6683e46fc00b3f081920dd5b1", "signature" => "da92708b8f2c9dcd7ecdc91d52946c01802833e6683e46fc00b3f081920dd5b1",
"body-mime" => load_message('mailgun_message2.txt') "body-mime" => load_message('mailgun_message2.txt')
} }
assert_response :success assert_response :success
assert_equal(todo_count+1, Todo.count) assert_equal(todo_count+1, Todo.count)
message_todo = Todo.where(:description => "test").first message_todo = Todo.where(:description => "test").first
assert_not_nil(message_todo) assert_not_nil(message_todo)
assert_equal(@inbox, message_todo.context) assert_equal(@inbox, message_todo.context)
assert_equal(@user, message_todo.user) assert_equal(@user, message_todo.user)
end
end end
def test_mailgun_signature_fails def test_mailgun_signature_fails
SITE_CONFIG['mailgun_api_key'] = "invalidkey" stub_site_config do
SITE_CONFIG['email_dispatch'] = 'from' SITE_CONFIG['mailgun_api_key'] = "invalidkey"
SITE_CONFIG['email_dispatch'] = 'from'
post :mailgun, { post :mailgun, {
"timestamp" => "1379539674", "timestamp" => "1379539674",
"token" => "5km6cwo0e3bfvg78hw4s69znro09xhk1h8u6-s633yasc8hcr5", "token" => "5km6cwo0e3bfvg78hw4s69znro09xhk1h8u6-s633yasc8hcr5",
"signature" => "da92708b8f2c9dcd7ecdc91d52946c01802833e6683e46fc00b3f081920dd5b1", "signature" => "da92708b8f2c9dcd7ecdc91d52946c01802833e6683e46fc00b3f081920dd5b1",
"body-mime" => load_message('mailgun_message1.txt') "body-mime" => load_message('mailgun_message1.txt')
} }
assert_response 406 assert_response 406
end
end end
end end

View file

@ -1,6 +1,8 @@
require 'test_helper' require 'test_helper'
require 'support/html_entity_helper'
class ProjectsControllerTest < ActionController::TestCase class ProjectsControllerTest < ActionController::TestCase
include HTMLEntityHelper
def setup def setup
end end
@ -83,7 +85,7 @@ class ProjectsControllerTest < ActionController::TestCase
assert_equal 'application/rss+xml', @response.content_type assert_equal 'application/rss+xml', @response.content_type
#puts @response.body #puts @response.body
assert_xml_select 'rss[version="2.0"]' do assert_select 'rss[version="2.0"]' do
assert_select 'channel' do assert_select 'channel' do
assert_select '>title', 'Tracks Projects' assert_select '>title', 'Tracks Projects'
assert_select '>description', "Lists all the projects for #{users(:admin_user).display_name}" assert_select '>description', "Lists all the projects for #{users(:admin_user).display_name}"
@ -94,7 +96,7 @@ class ProjectsControllerTest < ActionController::TestCase
assert_select 'title', /.+/ assert_select 'title', /.+/
assert_select 'description' do assert_select 'description' do
assert_select_encoded do assert_select_encoded do
assert_select 'p', /^\d+&nbsp;actions\. Project is (active|hidden|completed)\.$/ assert_select 'p', /^\d+#{nbsp}actions\. Project is (active|hidden|completed)\.$/
end end
end end
%w(guid link).each do |node| %w(guid link).each do |node|
@ -127,16 +129,15 @@ class ProjectsControllerTest < ActionController::TestCase
login_as :admin_user login_as :admin_user
get :index, { :format => "atom" } get :index, { :format => "atom" }
assert_equal 'application/atom+xml', @response.content_type assert_equal 'application/atom+xml', @response.content_type
# puts @response.body assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
assert_select 'feed' do
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do
assert_select '>title', 'Tracks Projects' assert_select '>title', 'Tracks Projects'
assert_select '>subtitle', "Lists all the projects for #{users(:admin_user).display_name}" assert_select '>subtitle', "Lists all the projects for #{users(:admin_user).display_name}"
assert_select 'entry', 3 do assert_select 'entry', 3 do
assert_select 'title', /.+/ assert_select 'title', /.+/
assert_select 'content[type="html"]' do assert_select 'content[type="html"]' do
assert_select_encoded do assert_select_encoded do
assert_select 'p', /\d+&nbsp;actions. Project is (active|hidden|completed)./ assert_select 'p', /\d+#{nbsp}actions. Project is (active|hidden|completed)./
end end
end end
assert_select 'published', /(#{Regexp.escape(projects(:timemachine).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/ assert_select 'published', /(#{Regexp.escape(projects(:timemachine).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/
@ -239,7 +240,7 @@ class ProjectsControllerTest < ActionController::TestCase
get :index, { :format => "xml" } get :index, { :format => "xml" }
assert_equal 'application/xml', @response.content_type assert_equal 'application/xml', @response.content_type
assert_xml_select 'projects' do assert_select 'projects' do
assert_select 'project', 3 do assert_select 'project', 3 do
assert_select 'name', /.+/ assert_select 'name', /.+/
assert_select 'state', 'active' assert_select 'state', 'active'

View file

@ -1,7 +1,6 @@
require 'test_helper' require 'test_helper'
class TodosControllerTest < ActionController::TestCase class TodosControllerTest < ActionController::TestCase
def test_get_index_when_not_logged_in def test_get_index_when_not_logged_in
get :index get :index
assert_redirected_to login_url assert_redirected_to login_url
@ -235,8 +234,8 @@ class TodosControllerTest < ActionController::TestCase
"project_name"=>"Build a working time machine", "project_name"=>"Build a working time machine",
"todo"=>{"notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar" } "todo"=>{"notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar" }
assert_response 409 assert_response 409
assert_xml_select "errors" do assert_select "errors" do
assert_xml_select "error", "Context can't be blank" assert_select "error", "Context can't be blank"
end end
end end
@ -467,7 +466,7 @@ class TodosControllerTest < ActionController::TestCase
assert_equal 'application/rss+xml', @response.content_type assert_equal 'application/rss+xml', @response.content_type
# puts @response.body # puts @response.body
assert_xml_select 'rss[version="2.0"]' do assert_select 'rss[version="2.0"]' do
assert_select 'channel' do assert_select 'channel' do
assert_select '>title', 'Tracks Actions' assert_select '>title', 'Tracks Actions'
assert_select '>description', "Actions for #{users(:admin_user).display_name}" assert_select '>description', "Actions for #{users(:admin_user).display_name}"
@ -488,7 +487,7 @@ class TodosControllerTest < ActionController::TestCase
login_as(:admin_user) login_as(:admin_user)
get :index, { :format => "rss", :limit => '5' } get :index, { :format => "rss", :limit => '5' }
assert_xml_select 'rss[version="2.0"]' do assert_select 'rss[version="2.0"]' do
assert_select 'channel' do assert_select 'channel' do
assert_select '>title', 'Tracks Actions' assert_select '>title', 'Tracks Actions'
assert_select '>description', "Actions for #{users(:admin_user).display_name}" assert_select '>description', "Actions for #{users(:admin_user).display_name}"
@ -522,15 +521,14 @@ class TodosControllerTest < ActionController::TestCase
login_as :admin_user login_as :admin_user
get :index, { :format => "atom" } get :index, { :format => "atom" }
assert_equal 'application/atom+xml', @response.content_type assert_equal 'application/atom+xml', @response.content_type
# #puts @response.body assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
assert_select 'feed' do
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do assert_select '>title', 'Tracks Actions'
assert_xml_select '>title', 'Tracks Actions' assert_select '>subtitle', "Actions for #{users(:admin_user).display_name}"
assert_xml_select '>subtitle', "Actions for #{users(:admin_user).display_name}" assert_select 'entry', 17 do
assert_xml_select 'entry', 17 do assert_select 'title', /.+/
assert_xml_select 'title', /.+/ assert_select 'content[type="html"]', /.*/
assert_xml_select 'content[type="html"]', /.*/ assert_select 'published', /(#{Regexp.escape(todos(:book).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/
assert_xml_select 'published', /(#{Regexp.escape(todos(:book).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/
end end
end end
end end
@ -846,7 +844,7 @@ class TodosControllerTest < ActionController::TestCase
todo.notes = "foo #{url} bar" todo.notes = "foo #{url} bar"
todo.save! todo.save!
get :index get :index
assert_select "a[href=#{url}]" assert_select "a[href='#{url}']"
end end
def test_link_opened_in_new_window def test_link_opened_in_new_window
@ -886,7 +884,7 @@ class TodosControllerTest < ActionController::TestCase
todo.save! todo.save!
get :index get :index
assert_select("div#notes_todo_#{todo.id}", 'A link to http://github.com/.') assert_select("div#notes_todo_#{todo.id}", 'A link to http://github.com/.')
assert_select("div#notes_todo_#{todo.id} a[href=http://github.com/]", 'http://github.com/') assert_select("div#notes_todo_#{todo.id} a[href='http://github.com/']", 'http://github.com/')
end end
def test_format_note_link_message def test_format_note_link_message
@ -895,9 +893,9 @@ class TodosControllerTest < ActionController::TestCase
todo.raw_notes = "A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link" todo.raw_notes = "A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link"
todo.save! todo.save!
get :index get :index
assert_select("div#notes_todo_#{todo.id}", 'A Mail.app message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt; link') assert_select("div#notes_todo_#{todo.id}", 'A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link')
assert_select("div#notes_todo_#{todo.id} a", 'message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt;') assert_select("div#notes_todo_#{todo.id} a", 'message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>')
assert_select("div#notes_todo_#{todo.id} a[href=message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt;]", 'message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt;') assert_select("div#notes_todo_#{todo.id} a[href='message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>']", "message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>")
end end
def test_format_note_link_onenote def test_format_note_link_onenote
@ -908,7 +906,7 @@ class TodosControllerTest < ActionController::TestCase
get :index get :index
assert_select("div#notes_todo_#{todo.id}", 'link me to onenote') assert_select("div#notes_todo_#{todo.id}", 'link me to onenote')
assert_select("div#notes_todo_#{todo.id} a", 'link me to onenote') assert_select("div#notes_todo_#{todo.id} a", 'link me to onenote')
assert_select("div#notes_todo_#{todo.id} a[href=onenote:///E:%5COneNote%5Cdir%5Cnotes.one#PAGE&amp;section-id=%7BFD597D3A-3793-495F-8345-23D34A00DD3B%7D&amp;page-id=%7B1C95A1C7-6408-4804-B3B5-96C28426022B%7D&amp;end]", 'link me to onenote') assert_select("div#notes_todo_#{todo.id} a[href='onenote:///E:%5COneNote%5Cdir%5Cnotes.one#PAGE&section-id=%7BFD597D3A-3793-495F-8345-23D34A00DD3B%7D&page-id=%7B1C95A1C7-6408-4804-B3B5-96C28426022B%7D&end']", 'link me to onenote')
end end
############## ##############

View file

@ -5,23 +5,23 @@ class TodosHelpersTest < ActionView::TestCase
test "remote_edit_button" do test "remote_edit_button" do
html = remote_edit_button(todos(:call_bill)) html = remote_edit_button(todos(:call_bill))
assert_equal "<a class=\"icon edit_item\" href=\"/todos/1/edit\" id=\"icon_edit_todo_1\" title=\"Edit the action &#39;Call Bill Gates to find out how much he makes per day&#39;\"><img align=\"absmiddle\" alt=\"Edit\" class=\"edit_item\" id=\"edit_icon_todo_1\" src=\"/images/blank.png\" /></a>", html assert_equal "<a class=\"icon edit_item\" id=\"icon_edit_todo_1\" title=\"Edit the action &#39;Call Bill Gates to find out how much he makes per day&#39;\" href=\"/todos/1/edit\"><img alt=\"Edit\" align=\"absmiddle\" id=\"edit_icon_todo_1\" class=\"edit_item\" src=\"/images/blank.png\" /></a>", html
end end
test "remote_delete_menu" do test "remote_delete_menu" do
html = remote_delete_menu_item(todos(:call_bill)) html = remote_delete_menu_item(todos(:call_bill))
assert_equal "<a class=\"icon_delete_item\" href=\"/todos/1\" id=\"delete_todo_1\" title=\"Delete action\" x_confirm_message=\"Are you sure that you want to delete the action &#39;Call Bill Gates to find out how much he makes per day&#39;?\">Delete</a>", html assert_equal "<a class=\"icon_delete_item\" id=\"delete_todo_1\" x_confirm_message=\"Are you sure that you want to delete the action &#39;Call Bill Gates to find out how much he makes per day&#39;?\" title=\"Delete action\" href=\"/todos/1\">Delete</a>", html
end end
test "remote_delete_dependency" do test "remote_delete_dependency" do
todo = todos(:call_bill_gates_every_day) todo = todos(:call_bill_gates_every_day)
predecessor = todos(:call_bill) predecessor = todos(:call_bill)
html = remote_delete_dependency(todo, predecessor) html = remote_delete_dependency(todo, predecessor)
assert_equal "<a class=\"delete_dependency_button\" href=\"/todos/18/remove_predecessor\" x_predecessors_id=\"1\"><img align=\"absmiddle\" alt=\"Blank\" class=\"delete_item\" src=\"/images/blank.png\" title=\"Remove dependency (does not delete the action)\" /></a>", html assert_equal "<a class=\"delete_dependency_button\" x_predecessors_id=\"1\" href=\"/todos/18/remove_predecessor\"><img title=\"Remove dependency (does not delete the action)\" align=\"absmiddle\" class=\"delete_item\" src=\"/images/blank.png\" alt=\"Blank\" /></a>", html
end end
test "remote_promote_to_project_menu_item" do test "remote_promote_to_project_menu_item" do
html = remote_promote_to_project_menu_item(todos(:call_bill)) html = remote_promote_to_project_menu_item(todos(:call_bill))
assert_equal "<a class=\"icon_item_to_project\" href=\"/todos/1/convert_to_project?_source_view=\" id=\"to_project_todo_1\">Make project</a>", html assert_equal "<a class=\"icon_item_to_project\" id=\"to_project_todo_1\" href=\"/todos/1/convert_to_project?_source_view=\">Make project</a>", html
end end
end end

View file

@ -6,11 +6,12 @@ class ProjectXmlApiTest < ActionDispatch::IntegrationTest
def test_retrieve_project def test_retrieve_project
authenticated_get_xml "/projects/1.xml", users(:admin_user).login, 'abracadabra', {} authenticated_get_xml "/projects/1.xml", users(:admin_user).login, 'abracadabra', {}
assert_tag :tag => "project" assert_select 'project' do
assert_tag :tag => "project", :child => {:tag => "not_done" } assert_select 'not_done'
assert_tag :tag => "project", :child => {:tag => "deferred" } assert_select 'deferred'
assert_tag :tag => "project", :child => {:tag => "pending" } assert_select 'pending'
assert_tag :tag => "project", :child => {:tag => "done" } assert_select 'done'
end
assert_response 200 assert_response 200
end end

View file

@ -1,6 +1,8 @@
require 'test_helper' require 'test_helper'
require 'support/stub_site_config_helper'
class StoriesTest < ActionDispatch::IntegrationTest class StoriesTest < ActionDispatch::IntegrationTest
include StubSiteConfigHelper
# #################################################### # ####################################################
# Testing login and signup by different kinds of users # Testing login and signup by different kinds of users
@ -14,23 +16,27 @@ class StoriesTest < ActionDispatch::IntegrationTest
end end
def test_signup_new_user_by_nonadmin def test_signup_new_user_by_nonadmin
SITE_CONFIG['open_signups'] = false stub_site_config do
other_user = new_session_as(:other_user,"sesame") SITE_CONFIG['open_signups'] = false
other_user.goes_to_signup_as_nonadmin other_user = new_session_as(:other_user,"sesame")
other_user.goes_to_signup_as_nonadmin
end
end end
def test_open_signup_new_user def test_open_signup_new_user
SITE_CONFIG['open_signups'] = true stub_site_config do
get "/signup" SITE_CONFIG['open_signups'] = true
assert_response :success get "/signup"
assert_template "users/new" assert_response :success
post "/users", :user => {:login => "newbie", assert_template "users/new"
:password => "newbiepass", post "/users", :user => {:login => "newbie",
:password_confirmation => "newbiepass"} :password => "newbiepass",
assert_response :redirect :password_confirmation => "newbiepass"}
follow_redirect! assert_response :redirect
assert_response :success follow_redirect!
assert_template "todos/index" assert_response :success
assert_template "todos/index"
end
end end
private private

View file

@ -24,12 +24,14 @@ class TodoXmlApiTest < ActionDispatch::IntegrationTest
def test_get_tickler_returns_all_deferred_and_pending_todos def test_get_tickler_returns_all_deferred_and_pending_todos
number = @user.todos.deferred.count + @user.todos.pending.count number = @user.todos.deferred.count + @user.todos.pending.count
authenticated_get_xml "/tickler.xml", @user.login, @password, {} authenticated_get_xml "/tickler.xml", @user.login, @password, {}
assert_tag :tag => "todos", :children => { :count => number } assert_select 'todos' do
assert_select 'todo', count: number
end
end end
def test_get_tickler_omits_user_id def test_get_tickler_omits_user_id
authenticated_get_xml "/tickler.xml", @user.login, @password, {} authenticated_get_xml "/tickler.xml", @user.login, @password, {}
assert_no_tag :tag => "user_id" assert_select 'user_id', false
end end
def test_get_index_with_only_active_todos def test_get_index_with_only_active_todos
@ -245,7 +247,7 @@ class TodoXmlApiTest < ActionDispatch::IntegrationTest
<project_id type='integer'>-11</project_id> <project_id type='integer'>-11</project_id>
</todo>" </todo>"
assert_response 409 assert_response 409
assert_xml_select 'errors' do assert_select 'errors' do
assert_select 'error', 2 assert_select 'error', 2
end end
end end
@ -261,4 +263,4 @@ class TodoXmlApiTest < ActionDispatch::IntegrationTest
authenticated_post_xml "/todos.xml", user, password, postdata authenticated_post_xml "/todos.xml", user, password, postdata
end end
end end

View file

@ -69,16 +69,17 @@ class UsersXmlApiTest < ActionDispatch::IntegrationTest
def test_get_users_as_xml def test_get_users_as_xml
get '/users.xml', {}, basic_auth_headers() get '/users.xml', {}, basic_auth_headers()
assert_response :success assert_response :success
assert_tag :tag => "users", assert_select 'users' do
:children => { :count => 4, :only => { :tag => "user" } } assert_select 'user', count: 4
assert_no_tag :tag => "password" end
assert_select 'password', false
end end
def test_get_user_as_xml def test_get_user_as_xml
get "/users/#{users(:other_user).id}.xml", {}, basic_auth_headers() get "/users/#{users(:other_user).id}.xml", {}, basic_auth_headers()
assert_response :success assert_response :success
assert_tag :tag => "user" assert_select 'user'
assert_no_tag :tag => "password" assert_select 'password', false
end end
private private

View file

@ -0,0 +1,11 @@
require 'htmlentities'
module HTMLEntityHelper
def entity(name)
HTMLEntities.new.decode("&#{name};")
end
def nbsp
entity('nbsp')
end
end

View file

@ -0,0 +1,9 @@
require 'minitest/stub_const'
module StubSiteConfigHelper
def stub_site_config
Object.stub_const(:SITE_CONFIG, SITE_CONFIG.clone) do
yield
end
end
end

View file

@ -56,15 +56,6 @@ class ActiveSupport::TestCase
def assert_equal_dmy(date1, date2) def assert_equal_dmy(date1, date2)
assert_equal date1.strftime("%d-%m-%y"), date2.strftime("%d-%m-%y") assert_equal date1.strftime("%d-%m-%y"), date2.strftime("%d-%m-%y")
end end
def xml_document
@xml_document ||= HTML::Document.new(@response.body, false, true)
end
def assert_xml_select(*args, &block)
@html_document = xml_document
assert_select(*args, &block)
end
end end
class ActionController::TestCase class ActionController::TestCase
@ -90,11 +81,6 @@ class ActionController::TestCase
xhr :post, :create, get_model_class.downcase => {:name => name} xhr :post, :create, get_model_class.downcase => {:name => name}
end end
def assert_xml_select(*args, &block)
@html_document = xml_document
assert_select(*args, &block)
end
private private
def get_model_class def get_model_class
@ -145,7 +131,7 @@ class ActionDispatch::IntegrationTest
def assert_responses_with_error(error_msg) def assert_responses_with_error(error_msg)
assert_response 409 assert_response 409
assert_xml_select 'errors' do assert_select 'errors' do
assert_select 'error', 1, error_msg assert_select 'error', 1, error_msg
end end
end end