Commit 3559327655dc6ee0b12130728261ccca6e4245e5

Authored by Victor Costa
2 parents 2e22079c 4345bcc8

Merge branch 'master' into stable

app/helpers/application_helper.rb
... ... @@ -1380,7 +1380,7 @@ module ApplicationHelper
1380 1380 # are old things that do not support it we are keeping this hot spot.
1381 1381 html = @plugins.pipeline(:parse_content, html, source).first
1382 1382 end
1383   - html.html_safe
  1383 + html && html.html_safe
1384 1384 end
1385 1385  
1386 1386 def convert_macro(html, source)
... ...
db/migrate/20140724134601_fix_yaml_encoding.rb
1 1 class FixYamlEncoding < ActiveRecord::Migration
2 2 def self.up
3   - fix_encoding(Block, 'settings')
4   - fix_encoding(Product, 'data')
5   - fix_encoding(Environment, 'settings')
6   - fix_encoding(Profile, 'data')
7   - fix_encoding(ActionTracker::Record, 'params')
8   - fix_encoding(Article, 'setting')
9   - fix_encoding(Task, 'data')
  3 + ActiveRecord::Base.transaction do
  4 + fix_encoding(Environment, 'settings')
  5 + fix_encoding(Profile, 'data')
  6 + fix_encoding(Product, 'data')
  7 + fix_encoding(ActionTracker::Record, 'params')
  8 + fix_encoding(Article, 'setting')
  9 + fix_encoding(Task, 'data')
  10 + fix_encoding(Block, 'settings')
  11 + end
10 12 end
11 13  
12 14 def self.down
... ... @@ -16,15 +18,34 @@ class FixYamlEncoding &lt; ActiveRecord::Migration
16 18 private
17 19  
18 20 def self.fix_encoding(model, param)
19   - result = model.find(:all, :conditions => "#{param} LIKE '%!binary%'")
  21 + result = model.all
20 22 puts "Fixing #{result.count} rows of #{model} (#{param})"
21   - result.each {|r| r.update_column(param, deep_fix(r.send(param)).to_yaml)}
  23 + result.each do |r|
  24 + begin
  25 + yaml = r.send(param)
  26 + # if deserialization failed then a string is returned
  27 + if yaml.is_a? String
  28 + yaml.gsub! ': `', ': '
  29 + yaml = YAML.load yaml
  30 + end
  31 + r.update_column param, deep_fix(yaml).to_yaml
  32 + rescue => e
  33 + puts "FAILED #{r.inspect}"
  34 + puts e.message
  35 + end
  36 + end
22 37 end
23 38  
24 39 def self.deep_fix(hash)
25 40 hash.each do |value|
26   - value.force_encoding('UTF-8') if value.is_a?(String) && !value.frozen? && value.encoding == Encoding::ASCII_8BIT
27 41 deep_fix(value) if value.respond_to?(:each)
  42 + if value.is_a? String and not value.frozen?
  43 + if value.encoding == Encoding::ASCII_8BIT
  44 + value.force_encoding "utf-8"
  45 + else
  46 + value.encode!("iso-8859-1").force_encoding("utf-8")
  47 + end
  48 + end
28 49 end
29 50 end
30 51  
... ...
plugins/remote_user/test/functional/remote_user_plugin_test.rb
... ... @@ -61,6 +61,8 @@ class AccountControllerTest &lt; ActionController::TestCase
61 61 end
62 62  
63 63 should 'create a new user with remote_user_data even if there is a logged user but the remote user is different' do
  64 + users = User.count
  65 +
64 66 user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test')
65 67 user.activate
66 68  
... ... @@ -71,7 +73,7 @@ class AccountControllerTest &lt; ActionController::TestCase
71 73 @request.env["HTTP_REMOTE_USER_DATA"] = '{"email":"another_user@domain.com", "name":"Another User"}'
72 74 get :index
73 75  
74   - assert_equal 2, User.count
  76 + assert_equal users + 2, User.count
75 77 assert_equal "another_user", User.last.login
76 78 assert_equal true, User.last.activated?
77 79 assert_equal User.last.id, session[:user]
... ... @@ -96,6 +98,8 @@ class AccountControllerTest &lt; ActionController::TestCase
96 98 end
97 99  
98 100 should 'create a new user without remote_user_data even if there is a logged user but the remote user is different' do
  101 + users = User.count
  102 +
99 103 user = create_user('testuser', :email => 'testuser@example.com', :password => 'test', :password_confirmation => 'test')
100 104 user.activate
101 105  
... ... @@ -104,7 +108,7 @@ class AccountControllerTest &lt; ActionController::TestCase
104 108 @request.env["HTTP_REMOTE_USER"] = 'another_user'
105 109 get :index
106 110  
107   - assert_equal 2, User.count
  111 + assert_equal users + 2, User.count
108 112 assert_equal "another_user", User.last.login
109 113 assert_equal true, User.last.activated?
110 114 assert_equal User.last.id, session[:user]
... ...
script/development
... ... @@ -5,8 +5,13 @@ set -e
5 5 export RAILS_ENV=development
6 6  
7 7 stop() {
  8 + echo "Stopping ..."
8 9 ./script/delayed_job stop
9 10 ./script/feed-updater stop
  11 + if [ -f tmp/pids/thin.pid ]; then
  12 + kill -9 $(cat tmp/pids/thin.pid)
  13 + rm -f tmp/pids/thin.pid
  14 + fi
10 15 exit
11 16 }
12 17  
... ... @@ -15,7 +20,18 @@ start() {
15 20 ./script/feed-updater start
16 21 ./script/delayed_job start
17 22 trap stop INT TERM
18   - rails s $@
  23 + if [ -z "$RAILS_RELATIVE_URL_ROOT" ]; then
  24 + rails s $@
  25 + else
  26 + mkdir -p log
  27 + touch log/development.log
  28 + thin \
  29 + --prefix "$RAILS_RELATIVE_URL_ROOT" \
  30 + --pid tmp/pids/thin.pid \
  31 + --daemonize \
  32 + start
  33 + tail -n 0 -f log/development.log || true
  34 + fi
19 35 }
20 36  
21 37 start $@
... ...
script/silent-quick-start 0 → 100755
... ... @@ -0,0 +1,13 @@
  1 +#!/bin/sh
  2 +
  3 +set -e
  4 +
  5 +mkdir -p log
  6 +
  7 +rc=0
  8 +./script/quick-start > log/quick-start.log 2>&1 || rc=$?
  9 +
  10 +if [ $rc -ne 0 ]; then
  11 + cat log/quick-start.log
  12 + exit $rc
  13 +fi
... ...