diff options
Diffstat (limited to 'activeresource')
-rw-r--r-- | activeresource/Rakefile | 10 | ||||
-rw-r--r-- | activeresource/activeresource.gemspec | 37 | ||||
-rw-r--r-- | activeresource/lib/active_resource/observing.rb | 13 | ||||
-rw-r--r-- | activeresource/lib/active_resource/validations.rb | 4 | ||||
-rw-r--r-- | activeresource/lib/activeresource.rb | 1 | ||||
-rw-r--r-- | activeresource/test/cases/base_errors_test.rb | 4 | ||||
-rw-r--r-- | activeresource/test/cases/observing_test.rb | 2 | ||||
-rw-r--r-- | activeresource/test/cases/validations_test.rb | 3 |
8 files changed, 66 insertions, 8 deletions
diff --git a/activeresource/Rakefile b/activeresource/Rakefile index def489fad9..54c3fe44c6 100644 --- a/activeresource/Rakefile +++ b/activeresource/Rakefile @@ -34,11 +34,12 @@ Rake::TestTask.new { |t| t.verbose = true t.warning = true } + task :isolated_test do ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) activesupport_path = "#{File.dirname(__FILE__)}/../activesupport/lib" Dir.glob("test/**/*_test.rb").all? do |file| - system(ruby, "-Ilib:test:#{activesupport_path}", file) + system(ruby, '-w', "-Ilib:test:#{activesupport_path}", file) end or raise "Failures" end @@ -74,6 +75,7 @@ spec = Gem::Specification.new do |s| end s.add_dependency('activesupport', '= 3.0.pre' + PKG_BUILD) + s.add_dependency('activemodel', '= 3.0.pre' + PKG_BUILD) s.require_path = 'lib' s.autorequire = 'active_resource' @@ -94,6 +96,12 @@ Rake::GemPackageTask.new(spec) do |p| p.need_zip = true end +task :gemspec do + File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w") do |file| + file.puts spec.to_ruby + end +end + task :lines do lines, codelines, total_lines, total_codelines = 0, 0, 0, 0 diff --git a/activeresource/activeresource.gemspec b/activeresource/activeresource.gemspec new file mode 100644 index 0000000000..c3bb6e3622 --- /dev/null +++ b/activeresource/activeresource.gemspec @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{activeresource} + s.version = "3.0.pre" + + s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= + s.authors = ["David Heinemeier Hansson"] + s.autorequire = %q{active_resource} + s.date = %q{2009-09-01} + s.description = %q{Wraps web resources in model classes that can be manipulated through XML over REST.} + s.email = %q{david@loudthinking.com} + s.extra_rdoc_files = ["README"] + s.files = ["Rakefile", "README", "CHANGELOG", "lib/active_resource", "lib/active_resource/base.rb", "lib/active_resource/connection.rb", "lib/active_resource/custom_methods.rb", "lib/active_resource/exceptions.rb", "lib/active_resource/formats", "lib/active_resource/formats/json_format.rb", "lib/active_resource/formats/xml_format.rb", "lib/active_resource/formats.rb", "lib/active_resource/http_mock.rb", "lib/active_resource/observing.rb", "lib/active_resource/validations.rb", "lib/active_resource/version.rb", "lib/active_resource.rb", "lib/activeresource.rb", "test/abstract_unit.rb", "test/cases", "test/cases/authorization_test.rb", "test/cases/base", "test/cases/base/custom_methods_test.rb", "test/cases/base/equality_test.rb", "test/cases/base/load_test.rb", "test/cases/base_errors_test.rb", "test/cases/base_test.rb", "test/cases/finder_test.rb", "test/cases/format_test.rb", "test/cases/observing_test.rb", "test/cases/validations_test.rb", "test/connection_test.rb", "test/debug.log", "test/fixtures", "test/fixtures/beast.rb", "test/fixtures/customer.rb", "test/fixtures/person.rb", "test/fixtures/project.rb", "test/fixtures/proxy.rb", "test/fixtures/street_address.rb", "test/setter_trap.rb", "examples/simple.rb"] + s.homepage = %q{http://www.rubyonrails.org} + s.rdoc_options = ["--main", "README"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{activeresource} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Think Active Record for web resources.} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q<activesupport>, ["= 3.0.pre"]) + s.add_runtime_dependency(%q<activemodel>, ["= 3.0.pre"]) + else + s.add_dependency(%q<activesupport>, ["= 3.0.pre"]) + s.add_dependency(%q<activemodel>, ["= 3.0.pre"]) + end + else + s.add_dependency(%q<activesupport>, ["= 3.0.pre"]) + s.add_dependency(%q<activemodel>, ["= 3.0.pre"]) + end +end diff --git a/activeresource/lib/active_resource/observing.rb b/activeresource/lib/active_resource/observing.rb index 94836f4bb1..3c74d49c80 100644 --- a/activeresource/lib/active_resource/observing.rb +++ b/activeresource/lib/active_resource/observing.rb @@ -4,7 +4,18 @@ module ActiveResource include ActiveModel::Observing included do - wrap_with_notifications :create, :save, :update, :destroy + %w( create save update destroy ).each do |method| + class_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{method}_with_notifications(*args, &block) + notify_observers(:before_#{method}) + if result = #{method}_without_notifications(*args, &block) + notify_observers(:after_#{method}) + end + result + end + EOS + alias_method_chain(method, :notifications) + end end end end diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb index d4d282e273..67b69fa505 100644 --- a/activeresource/lib/active_resource/validations.rb +++ b/activeresource/lib/active_resource/validations.rb @@ -93,9 +93,9 @@ module ActiveResource # content-type of the error-block received def load_remote_errors(remote_errors, save_cache = false ) #:nodoc: case remote_errors.response['Content-Type'] - when 'application/xml' + when /xml/ errors.from_xml(remote_errors.response.body, save_cache) - when 'application/json' + when /json/ errors.from_json(remote_errors.response.body, save_cache) end end diff --git a/activeresource/lib/activeresource.rb b/activeresource/lib/activeresource.rb deleted file mode 100644 index e076455b16..0000000000 --- a/activeresource/lib/activeresource.rb +++ /dev/null @@ -1 +0,0 @@ -require 'active_resource' diff --git a/activeresource/test/cases/base_errors_test.rb b/activeresource/test/cases/base_errors_test.rb index eca00e9ca8..1eb7765132 100644 --- a/activeresource/test/cases/base_errors_test.rb +++ b/activeresource/test/cases/base_errors_test.rb @@ -4,8 +4,8 @@ require "fixtures/person" class BaseErrorsTest < Test::Unit::TestCase def setup ActiveResource::HttpMock.respond_to do |mock| - mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml'} - mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json'} + mock.post "/people.xml", {}, %q(<?xml version="1.0" encoding="UTF-8"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>), 422, {'Content-Type' => 'application/xml; charset=utf-8'} + mock.post "/people.json", {}, %q({"errors":["Age can't be blank","Name can't be blank","Name must start with a letter","Person quota full for today."]}), 422, {'Content-Type' => 'application/json; charset=utf-8'} end end diff --git a/activeresource/test/cases/observing_test.rb b/activeresource/test/cases/observing_test.rb index 334b256772..9599ff7b0f 100644 --- a/activeresource/test/cases/observing_test.rb +++ b/activeresource/test/cases/observing_test.rb @@ -1,4 +1,6 @@ require 'abstract_unit' +require 'fixtures/person' +require 'active_support/core_ext/hash/conversions' class ObservingTest < Test::Unit::TestCase cattr_accessor :history diff --git a/activeresource/test/cases/validations_test.rb b/activeresource/test/cases/validations_test.rb index a8ab7d64e7..c05f625fb7 100644 --- a/activeresource/test/cases/validations_test.rb +++ b/activeresource/test/cases/validations_test.rb @@ -1,5 +1,6 @@ require 'abstract_unit' -require "fixtures/project" +require 'fixtures/project' +require 'active_support/core_ext/hash/conversions' # The validations are tested thoroughly under ActiveModel::Validations # This test case simply makes sur that they are all accessible by |