From 93dd7f69535b50d3b13550e0c40527474b477b57 Mon Sep 17 00:00:00 2001 From: Thilo Utke Date: Thu, 21 Jan 2016 11:07:31 +0100 Subject: [PATCH] install bundler version 1.11.2 --- .travis.yml | 2 ++ couch_potato.gemspec | 3 ++- lib/couch_potato.rb | 4 ++-- spec/unit/model_view_spec_spec.rb | 8 ++++---- spec/views_spec.rb | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 14203b1d..4eef3cab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,8 @@ gemfile: - gemfiles/active_support_4_0 - gemfiles/active_support_4_1 - gemfiles/active_support_4_2 +before_install: + gem install bundler --version 1.11.2 before_script: - sudo sh -c 'echo "[native_query_servers]" >> /etc/couchdb/local.ini' - sudo sh -c 'echo "erlang = {couch_native_process, start_link, []}" >> /etc/couchdb/local.ini' diff --git a/couch_potato.gemspec b/couch_potato.gemspec index 9077e537..2b1bcdd2 100644 --- a/couch_potato.gemspec +++ b/couch_potato.gemspec @@ -11,7 +11,8 @@ Gem::Specification.new do |s| s.version = CouchPotato::VERSION s.platform = Gem::Platform::RUBY - s.add_dependency 'json', '~> 1.6' + s.add_dependency 'oj' + s.add_dependency 'oj_mimic_json' s.add_dependency 'couchrest', '~>2.0.0.rc3' s.add_dependency 'activemodel', '~> 4.0' diff --git a/lib/couch_potato.rb b/lib/couch_potato.rb index 62a5d7d2..022e3c2d 100644 --- a/lib/couch_potato.rb +++ b/lib/couch_potato.rb @@ -1,9 +1,9 @@ require 'couchrest' -require 'json' +require 'oj' require 'ostruct' -JSON.create_id = 'ruby_class' +Oj.default_options = {mode: :compat} CouchRest.decode_json_objects = true module CouchPotato diff --git a/spec/unit/model_view_spec_spec.rb b/spec/unit/model_view_spec_spec.rb index fa17467a..c2fb16a6 100644 --- a/spec/unit/model_view_spec_spec.rb +++ b/spec/unit/model_view_spec_spec.rb @@ -26,14 +26,14 @@ describe CouchPotato::View::ModelViewSpec, '#map_function' do it "should include conditions" do spec = CouchPotato::View::ModelViewSpec.new Object, 'all', {:conditions => 'doc.closed = true'}, {} - expect(spec.map_function).to include('if(doc.ruby_class && doc.ruby_class == \'Object\' && (doc.closed = true))') + expect(spec.map_function).to include('if(doc.json_class && doc.json_class == \'Object\' && (doc.closed = true))') end it 'generates an erlang map function with a single key if the language is erlang' do spec = CouchPotato::View::ModelViewSpec.new Object, 'all', {:key => :name, :language => :erlang}, {} expect(spec.map_function).to eql_ignoring_indentation(<<-ERL fun({Doc}) -> - case proplists:get_value(<<"ruby_class">>, Doc) of + case proplists:get_value(<<"json_class">>, Doc) of <<"Object">> -> Key = proplists:get_value(<<"name">>, Doc, null), Emit(Key, 1); @@ -49,7 +49,7 @@ spec = CouchPotato::View::ModelViewSpec.new Object, 'all', {:key => [:code, :name], :language => :erlang}, {} expect(spec.map_function).to eql_ignoring_indentation(<<-ERL fun({Doc}) -> - case proplists:get_value(<<"ruby_class">>, Doc) of + case proplists:get_value(<<"json_class">>, Doc) of <<"Object">> -> Key_0 = proplists:get_value(<<"code">>, Doc, null), Key_1 = proplists:get_value(<<"name">>, Doc, null), @@ -78,7 +78,7 @@ it "should not include conditions when they are nil" do spec = CouchPotato::View::ModelViewSpec.new Object, 'all', {}, {} - expect(spec.map_function).to include('if(doc.ruby_class && doc.ruby_class == \'Object\')') + expect(spec.map_function).to include('if(doc.json_class && doc.json_class == \'Object\')') end it "should have a custom emit value when specified as symbol" do diff --git a/spec/views_spec.rb b/spec/views_spec.rb index abddee85..db48bf07 100644 --- a/spec/views_spec.rb +++ b/spec/views_spec.rb @@ -50,7 +50,7 @@ class ErlangBuild end it 'does not crash couchdb when a document does not have the key' do - build = {'ruby_class' => 'ErlangBuild'} + build = {'json_class' => 'ErlangBuild'} @db.couchrest_database.save_doc build results = @db.view(ErlangBuild.by_name(:key => nil))