Browse files

Fix multi_json deprecation warnings

  • Loading branch information...
1 parent 3d11d32 commit 369597cec99e3a1ac482e7ba847ee700ccd0827d @sferik sferik committed Apr 17, 2012
View
2 config/initializers/yaml_renderer.rb
@@ -2,6 +2,6 @@
# strip the object type (e.g. !ruby/ActiveRecord:Rubygem) from response
# TODO: Remove :yamlish once we know how to strip object type with to_yaml
ActionController::Renderers.add :yaml do |obj, options|
- data = options[:yamlish] ? MultiJson.decode(obj.to_json).to_yaml : obj.to_yaml
+ data = options[:yamlish] ? MultiJson.load(obj.to_json).to_yaml : obj.to_yaml
send_data data, :type => 'text/yaml'
end
View
4 features/step_definitions/webhook_steps.rb
@@ -19,15 +19,15 @@
WebMock.assert_requested(:post, web_hook_url, :times => 1)
request = WebMock::RequestRegistry.instance.requested_signatures.hash.keys.first
- json = MultiJson.decode(request.body)
+ json = MultiJson.load(request.body)
assert_equal gem_name, json["name"]
assert_equal version_number, json["version"]
end
Then /I should see "(.*)" under "(.*)" in (json|yaml)/ do |web_hook_url, gem_name, format|
if format == "json"
- data = MultiJson.decode(page.source)
+ data = MultiJson.load(page.source)
else
data = YAML.load(page.source)
end
View
4 test/functional/api/v1/activities_controller_test.rb
@@ -35,7 +35,7 @@ def should_return_just_updated_gems(gems)
should "return correct JSON for latest gems" do
get :latest, :format => :json
- should_return_latest_gems MultiJson.decode(@response.body)
+ should_return_latest_gems MultiJson.load(@response.body)
end
should "return correct YAML for latest gems" do
@@ -67,7 +67,7 @@ def should_return_just_updated_gems(gems)
should "return correct JSON for just_updated gems" do
get :just_updated, :format => :json
- should_return_just_updated_gems MultiJson.decode(@response.body)
+ should_return_just_updated_gems MultiJson.load(@response.body)
end
should "return correct YAML for just_updated gems" do
View
2 test/functional/api/v1/api_keys_controller_test.rb
@@ -70,7 +70,7 @@ def self.should_respond_to(format, to_meth = :to_s)
context "on GET to show" do
should_respond_to(:json) do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to(:yaml, :to_sym) do |body|
View
8 test/functional/api/v1/downloads_controller_test.rb
@@ -21,7 +21,7 @@ def self.should_respond_to(format)
end
should_respond_to(:json) do |body|
- MultiJson.decode(body)['total']
+ MultiJson.load(body)['total']
end
should_respond_to(:xml) do |body|
@@ -75,7 +75,7 @@ def self.should_respond_to(format, to_meth = :to_s)
end
should_respond_to(:json) do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to(:xml) do |body|
@@ -146,7 +146,7 @@ def self.should_respond_to(format)
end
should_respond_to(:json) do |body|
- MultiJson.decode(body)['gems']
+ MultiJson.load(body)['gems']
end
should_respond_to(:yaml) do |body|
@@ -178,7 +178,7 @@ def self.should_respond_to(format)
end
should_respond_to(:json) do |body|
- MultiJson.decode(body)['gems']
+ MultiJson.load(body)['gems']
end
should_respond_to(:yaml) do |body|
View
2 test/functional/api/v1/owners_controller_test.rb
@@ -36,7 +36,7 @@ def self.should_respond_to(format)
end
should_respond_to :json do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to :yaml do |body|
View
4 test/functional/api/v1/rubygems_controller_test.rb
@@ -59,7 +59,7 @@ def self.should_respond_to(format, &block)
context "On GET to show" do
should_respond_to(:json) do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to(:yaml) do |body|
@@ -136,7 +136,7 @@ def self.should_respond_to(format)
context "On GET to index" do
should_respond_to :json do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to :yaml do |body|
View
2 test/functional/api/v1/searches_controller_test.rb
@@ -39,7 +39,7 @@ def self.should_respond_to(format)
end
should_respond_to(:json) do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to(:xml) do |body|
View
4 test/functional/api/v1/versions/downloads_controller_test.rb
@@ -42,7 +42,7 @@ def self.should_respond_to(format)
end
should_respond_to(:json) do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to(:yaml) do |body|
@@ -156,7 +156,7 @@ def self.should_respond_to(format)
end
should_respond_to(:json) do |body|
- MultiJson.decode body
+ MultiJson.load body
end
should_respond_to(:yaml) do |body|
View
4 test/functional/api/v1/versions_controller_test.rb
@@ -48,7 +48,7 @@ def self.should_respond_to(format)
end
should_respond_to(:json) do |body|
- MultiJson.decode(body)
+ MultiJson.load(body)
end
should_respond_to(:xml) do |body|
@@ -84,7 +84,7 @@ def self.should_respond_to(format)
should "give all releases" do
get_show(@rubygem)
- assert_equal 12, MultiJson.decode(@response.body).size
+ assert_equal 12, MultiJson.load(@response.body).size
end
end
end
View
10 test/functional/api/v1/web_hooks_controller_test.rb
@@ -123,18 +123,18 @@ def self.should_respond_to(format)
context "On GET to index with some owned hooks" do
setup do
@rubygem_hook = create(:web_hook,
- :user => @user,
- :rubygem => @rubygem)
+ :user => @user,
+ :rubygem => @rubygem)
@global_hook = create(:global_web_hook,
- :user => @user)
+ :user => @user)
end
should_respond_to(:json) do |body|
- MultiJson.decode body
+ MultiJson.load(body)
end
should_respond_to(:yaml) do |body|
- YAML.load body
+ YAML.load(body)
end
should_respond_to(:xml) do |body|
View
2 test/unit/dependency_test.rb
@@ -16,7 +16,7 @@ class DependencyTest < ActiveSupport::TestCase
should "return JSON" do
@dependency.save
- json = MultiJson.decode(@dependency.to_json)
+ json = MultiJson.load(@dependency.to_json)
assert_equal %w[name requirements], json.keys.sort
assert_equal @dependency.rubygem.name, json["name"]
View
8 test/unit/rubygem_test.rb
@@ -248,7 +248,7 @@ class RubygemTest < ActiveSupport::TestCase
run_dep = create(:runtime_dependency, :version => version)
dev_dep = create(:development_dependency, :version => version)
- hash = MultiJson.decode(@rubygem.to_json)
+ hash = MultiJson.load(@rubygem.to_json)
assert_equal @rubygem.name, hash["name"]
assert_equal @rubygem.downloads, hash["downloads"]
@@ -259,8 +259,8 @@ class RubygemTest < ActiveSupport::TestCase
assert_equal "http://#{HOST}/gems/#{@rubygem.name}", hash["project_uri"]
assert_equal "http://#{HOST}/gems/#{@rubygem.versions.most_recent.full_name}.gem", hash["gem_uri"]
- assert_equal MultiJson.decode(dev_dep.to_json), hash["dependencies"]["development"].first
- assert_equal MultiJson.decode(run_dep.to_json), hash["dependencies"]["runtime"].first
+ assert_equal MultiJson.load(dev_dep.to_json), hash["dependencies"]["development"].first
+ assert_equal MultiJson.load(run_dep.to_json), hash["dependencies"]["runtime"].first
end
should "return a bunch of xml" do
@@ -291,7 +291,7 @@ class RubygemTest < ActiveSupport::TestCase
end
should "return a bunch of JSON" do
- hash = MultiJson.decode(@rubygem.to_json)
+ hash = MultiJson.load(@rubygem.to_json)
assert_equal @rubygem.linkset.home, hash["homepage_uri"]
assert_equal @rubygem.linkset.wiki, hash["wiki_uri"]
View
2 test/unit/user_test.rb
@@ -86,7 +86,7 @@ class UserTest < ActiveSupport::TestCase
end
should "only have email when boiling down to JSON" do
- json = MultiJson.decode(@user.to_json)
+ json = MultiJson.load(@user.to_json)
hash = {"email" => @user.email}
assert_equal hash, json
end
View
6 test/unit/web_hook_test.rb
@@ -74,7 +74,7 @@ class WebHookTest < ActiveSupport::TestCase
{
'url' => @url,
'failure_count' => @webhook.failure_count
- }, MultiJson.decode(@webhook.to_json))
+ }, MultiJson.load(@webhook.to_json))
end
should "show limited attributes for to_xml" do
@@ -144,7 +144,7 @@ class WebHookTest < ActiveSupport::TestCase
end
should "have gem properties encoded in JSON" do
- payload = MultiJson.decode(@job.payload)
+ payload = MultiJson.load(@job.payload)
assert_equal "foogem", payload['name']
assert_equal "3.2.1", payload['version']
assert_equal "DESC", payload["info"]
@@ -158,7 +158,7 @@ class WebHookTest < ActiveSupport::TestCase
new_version = create(:version, :number => "2.0.0", :rubygem => @rubygem)
new_hook = create(:web_hook)
job = Notifier.new(new_hook.url, 'localhost:1234', @rubygem, new_version)
- payload = MultiJson.decode(job.payload)
+ payload = MultiJson.load(job.payload)
assert_equal "foogem", payload['name']
assert_equal "2.0.0", payload['version']

0 comments on commit 369597c

Please sign in to comment.