From ef6293303480b319668bfdaca4e98492bc7e2451 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 29 Dec 2014 13:30:54 +1100 Subject: [PATCH] Ruby 2.2 fixes --- Gemfile | 3 +++ Gemfile.lock | 16 ++++++++-------- config/initializers/06-mini_profiler.rb | 5 ++++- spec/models/discourse_single_sign_on_spec.rb | 14 ++++++++++++++ spec/spec_helper.rb | 7 +++++-- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index e5837a1af71..ddf9def2857 100644 --- a/Gemfile +++ b/Gemfile @@ -245,6 +245,9 @@ gem 'rbtrace', require: false, platform: :mri gem 'ruby-readability', require: false gem 'simple-rss', require: false + +# TODO mri_22 should be here, but bundler was real slow to pick it up +# not even in production bundler yet, monkey patching it in feels bad gem 'gctools', require: false, platform: :mri_21 gem 'stackprof', require: false, platform: :mri_21 gem 'memory_profiler', require: false, platform: :mri_21 diff --git a/Gemfile.lock b/Gemfile.lock index cb946d0706d..cd0beb92b20 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GEM ember-source execjs handlebars-source (>= 1.0.0.rc.4) - better_errors (2.0.0) + better_errors (2.1.0) coderay (>= 1.0.0) erubis (>= 2.6.6) rack (>= 0.9.0) @@ -98,8 +98,8 @@ GEM fast_xs (0.8.0) fastimage (1.6.3) addressable (~> 2.3, >= 2.3.5) - ffi (1.9.5) - flamegraph (0.0.9) + ffi (1.9.6) + flamegraph (0.1.0) fast_stack fog (1.22.1) fog-brightbox @@ -134,7 +134,7 @@ GEM highline (1.6.21) hike (1.2.3) hiredis (0.5.2) - htmlentities (4.3.2) + htmlentities (4.3.3) i18n (0.6.11) image_optim (0.9.1) exifr (~> 1.1.3) @@ -196,7 +196,7 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (~> 1.2) - oj (2.10.2) + oj (2.11.1) omniauth (1.2.2) hashie (>= 1.2, < 4) rack (~> 1.0) @@ -273,8 +273,8 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) raindrops (0.13.0) - rake (10.4.0) - rake-compiler (0.9.3) + rake (10.4.2) + rake-compiler (0.9.4) rake rb-fsevent (0.9.4) rb-inotify (0.9.5) @@ -284,7 +284,7 @@ GEM msgpack (>= 0.4.3) trollop (>= 1.16.2) redcarpet (3.1.2) - redis (3.1.0) + redis (3.2.0) redis-namespace (1.5.1) redis (~> 3.0, >= 3.0.4) ref (1.0.5) diff --git a/config/initializers/06-mini_profiler.rb b/config/initializers/06-mini_profiler.rb index 11dc894fbf0..89254a7d2e4 100644 --- a/config/initializers/06-mini_profiler.rb +++ b/config/initializers/06-mini_profiler.rb @@ -2,7 +2,10 @@ if Rails.configuration.respond_to?(:load_mini_profiler) && Rails.configuration.load_mini_profiler require 'rack-mini-profiler' require 'flamegraph' - require 'memory_profiler' if RUBY_VERSION >= "2.1.0" + + # TODO support Ruby 2.2 once bundler fixes itself + require 'memory_profiler' if RUBY_VERSION >= "2.1.0" && RUBY_VERSION < "2.2.0" + # initialization is skipped so trigger it Rack::MiniProfilerRails.initialize!(Rails.application) end diff --git a/spec/models/discourse_single_sign_on_spec.rb b/spec/models/discourse_single_sign_on_spec.rb index 3f2d1c46460..a9668bbbcb5 100644 --- a/spec/models/discourse_single_sign_on_spec.rb +++ b/spec/models/discourse_single_sign_on_spec.rb @@ -34,6 +34,20 @@ describe DiscourseSingleSignOn do parsed.custom_fields["b.b"].should == "B.b" end + it "can do round trip parsing correctly" do + sso = SingleSignOn.new + sso.sso_secret = "test" + sso.name = "sam saffron" + sso.username = "sam" + sso.email = "sam@sam.com" + + sso = SingleSignOn.parse(sso.payload, "test") + + sso.name.should == "sam saffron" + sso.username.should == "sam" + sso.email.should == "sam@sam.com" + end + it "can lookup or create user when name is blank" do # so we can create system messages Fabricate(:admin) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3510c09401b..c58755c01c2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -110,8 +110,11 @@ Spork.prefork do end def freeze_time(now=Time.now) - DateTime.stubs(:now).returns(DateTime.parse(now.to_s)) - Time.stubs(:now).returns(Time.parse(now.to_s)) + datetime = DateTime.parse(now.to_s) + time = Time.parse(now.to_s) + + DateTime.stubs(:now).returns(datetime) + Time.stubs(:now).returns(time) end def file_from_fixtures(filename)