Commit Graph

10667 Commits

Author SHA1 Message Date
Jeremy Kemper
8bc3a14727 Benchmark script via miloops' arel fork via DataMapper's AR comparison script 2009-08-20 21:09:59 -07:00
taryn
328ba3b333 Added save! which raises ResourceInvalid unless valid?
Similar to Active Record - it will raise ActiveResouce::ResourceInvalid if
the resource is not valid (ie if <tt>valid?</tt> returns false)

However - does not raise ActiveResource::ResourceNotFound if the callbacks
fail (callbacks have not yet been implemented) - it will just try to save
and raise if the callbacks all fail.

This is not ideal behaviour - but will do until we decide to change the
behaviour of save_with_validations to actually raise (rather than catch) the
ResourceInvalid exception.

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:05:02 -05:00
taryn
4dc05bc8a9 Swallow ResourceNotFound error on find_every
Active Record does not explode with RecordNotFound if you go looking for a
collection of objects - it just returns nil. Thus Active Resource should
also not explode.

After all - finding no objects that match a set of conditions is not
exceptional behaviour - unlike looking for a specific object with a given id
(which you'd expect to exist).

I've also added documentation to +find+ to reflect this.

Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:04:48 -05:00
taryn
079ed8fc43 Pulled find-based tests into their own test case. This matches Active Record, and allows us to have one places where all find-tests are located, which will help when adding dynamic finders later.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:04:14 -05:00
taryn
36bf587347 Moved all test cases into a new test/cases directory to match Active Record test directory structure.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:03:57 -05:00
taryn
c2f90d6530 Added validations to ActiveResource. Added a smoke test to see if we can add a validation and use it, and add a validates callback and use it.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-19 09:03:17 -05:00
Mike Gunderloy
ef93524058 Remove sqlite2 build from CI recipe [#3066 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-18 13:24:39 +01:00
Pratik Naik
25e5b0c4a8 Remove support for SQLite 2.
If you're still using it, please install the plugin from git://github.com/rails/sqlite2_adapter.git
2009-08-17 14:54:34 +01:00
Joshua Peek
ff1b0d3c86 k, thats really slow, lets not 2009-08-16 21:21:39 -05:00
Joshua Peek
24ad9ae3d2 Cleanup route reloading in tests. Prefer with_routing over using ActionController::Routing::Routes directly 2009-08-16 21:14:26 -05:00
Yehuda Katz
ccf28d2499 Fixes ActionMailer regression [#3059 state:resolved] 2009-08-15 20:38:50 -07:00
Yehuda Katz
d6d550f0cb Missing fixture template -- fixes AP tests 2009-08-15 20:33:34 -07:00
Jay Pignata
7213da37ce Fix test_has_many_through_polymorphic_has_one on sqlite2 [#3054 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-15 19:14:32 -07:00
Jay Pignata
cb3e669b0d Fix calculation tests on sqlite2 [#3053 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-15 19:14:11 -07:00
Jeremy Kemper
76335c27b6 Bump pg gem requirement to 0.8.0. Build psql db with UTF8 encoding. 2009-08-15 19:04:25 -07:00
Jay Pignata
679128da58 Adding a call to logger from params_parser to give detailed debug information when invalid xml or json is posted
[#2481 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-08-15 16:51:03 -07:00
Joshua Peek
911acc10de Axe "best fit" generation support 2009-08-15 18:08:46 -05:00
Jeremy Kemper
df6617bc8a Normalize route generation order: associations, yield block, then own routes. 2009-08-15 15:56:52 -07:00
Yehuda Katz
1310231c15 Got tests to pass with some more changes.
* request.formats is much simpler now
    * For XHRs or Accept headers with a single item, we use the Accept header
    * For other requests, we use params[:format] or fallback to HTML
    * This is primarily to work around the fact that browsers provide completely
      broken Accept headers, so we have to whitelist the few cases we can
      specifically isolate and treat other requests as coming from the browser
    * For APIs, we can support single-item Accept headers, which disambiguates
      from the browsers
  * Requests to an action that only has an XML template from the browser will
    no longer find the template. This worked previously because most browsers
    provide a catch-all */*, but this was mostly accidental behavior. If you
    want to serve XML, either use the :xml format in links, or explicitly
    specify the XML template: render "template.xml".
2009-08-15 12:32:02 -07:00
Yehuda Katz
9b552fb300 Caches and cache clearing seems to actually work, but the actual architecture is kind of messy. Next: CLEAN UP. 2009-08-15 12:32:01 -07:00
Yehuda Katz
9f5cd0156a More cleanup of ActionView and reduction in need for blocks in some cases:
* only one of partial_name or :as will be available as a local
  * `object` is removed
  * Simplify _layout_for in most cases.
    * Remove <% render :partial do |args| %>
    * <% render :partial do %> still works fine
2009-08-15 12:32:01 -07:00
Yehuda Katz
27adcd1c1a Clean up ActionView some:
* Call _evaluate_assigns_and_ivars at the two entry points so we don't have to
    do a check at every render.
  * Make template.render viable without having to go through a wrapper method
  * Remove old TemplateHandler#render(template, local_assigns) path so we don't have
    to set self.template every time we render a template.
  * Move Template rescuing code to Template#render so it gets caught every time.
  * Pull in some tests from Pratik that test render @object in ActionView
2009-08-15 12:32:01 -07:00
Jatinder Singh
a363dba790 Fix ActiveResource load test for 64bit machines [#3051 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2009-08-15 20:29:37 +01:00
Jeremy Kemper
26e4d688ac Skip isolation test tests when using MiniTest 2009-08-15 12:28:09 -07:00
Joshua Peek
940a391c9b Attempt to rewrite most of the highly coupled router segments tests 2009-08-14 16:16:29 -05:00
Joshua Peek
f86a4b84dd Kill routing timed tests 2009-08-14 14:30:19 -05:00
Joshua Peek
c6bc8e6626 Break up concerns for choosing what attributes should be serialized and the actual serializer 2009-08-13 22:27:36 -05:00
Joshua Peek
7a26c21d8e Use safe tmp dir 2009-08-13 21:03:25 -05:00
José Valim
8692b11e81 Merge branch 'master' of git://github.com/rails/rails 2009-08-13 10:27:53 +02:00
José Valim
4f9047ecc8 Ensure collections are not treated as nested resources. 2009-08-13 10:27:41 +02:00
Chad Woolley
f413a703ba make mysql and postgresql rebuild databases on every CI build, to prevent breakages such as collation and character set changing
Signed-off-by: Yehuda Katz <wycats@gmail.com>
2009-08-12 00:11:16 -07:00
Yehuda Katz
ba67e256b8 Remove submodule 2009-08-11 23:44:44 -07:00
Yehuda Katz
27e880729e Made benchmarks submodule so it's easier to keep in sync 2009-08-11 16:49:27 -07:00
Yehuda Katz
ccd1c5e521 Allow superclass_delegating_accessor to take a block for initial set. 2009-08-11 15:03:53 -07:00
Yehuda Katz
4bf516e072 More perf work:
* Move #set_cookie and #delete_cookie inline to optimize. These optimizations should
    almost certainly be sent back upstream to Rack. The optimization involves using
    an ivar for cookies instead of indexing into the headers each time.
  * Was able to use a bare Hash for headers now that cookies have their own joining
    semantics (some code assumed that the raw cookies were an Array).
  * Cache blankness of body on body=
  * Improve expand_cache_key for Arrays of a single element (common in our case)
  * Use a simple layout condition check unless conditions are used
  * Cache visible actions
  * Lazily load the UrlRewriter
  * Make etag an ivar that is set on prepare!
2009-08-11 15:03:53 -07:00
Yehuda Katz
0adbeeb0c9 Got overhead down from 127 to 85. All tests pass:
* Tentatively replaced HeaderHash with SimpleHeaderHash, which does not preserve
    case but does handle converting Arrays to Strings in to_hash. This requires
    further discussion.
  * Moved default_charset to ActionDispatch::Response to avoid having to hop over
    to ActionController. Ideally, this would be a constant on AD::Response, but
    some tests expect to be able to change it dynamically and I didn't want to change
    them yet.
  * Completely override #initialize from Rack::Response. Previously, it was creating
    a HeaderHash, and then we were creating an entirely new one. There is no way to
    call super without incurring the overhead of creating a HeaderHash.
  * Override #write from Rack::Response. Its implementation tracks Content-Length,
    and doing so adds additional overhead that could be mooted if other middleware
    changes the body. It is more efficiently done at the top-level server.
  * Change sending_file to an instance_variable instead of header inspection. In
    general, if a state is important, it should be set as a property of the response
    not reconstructed later.
  * Set the Etag to @body instead of .body. AS::Cache.expand_cache_key handles
    Arrays fine, and it's more efficient to let it handle the body parts, since
    it is not forced to create a joined String.
  * If we detect the default cache control case, just set it, rather than setting
    the constituent parts and then running the normal (expensive) code to generate
    the string.
2009-08-11 15:03:53 -07:00
Yehuda Katz
9e62d6d1c0 Tentatively accept the ":as or :object, but not both" solution 2009-08-11 15:03:53 -07:00
Yehuda Katz
945a7df9f8 Make large_collection 1,000 partials 2009-08-11 15:03:53 -07:00
Yehuda Katz
4945d82239 Further experimentation. Was able to cut the cost of rendering 100 partials in a collection in half.
To discuss: What are the desired semantics (if any) for layouts in a collection. There are no
  tests for it at present, and I'm not sure if it's needed at all.

  Deprecated on this branch: `object` pointing at the current object in partials. You can still
  use the partial name, or use :as to achieve the same thing. This is obviously up for discussion.
2009-08-11 15:03:53 -07:00
Yehuda Katz
bef7576c09 Add a few more benches 2009-08-11 15:03:53 -07:00
Yehuda Katz
02d9dd9000 Add some more caching to the lookup 2009-08-11 15:03:52 -07:00
Yehuda Katz
04d4537cd4 This change causes some failing tests, but it should be possible to make them pass with minimal performance impact. 2009-08-11 15:03:52 -07:00
Pratik Naik
0a558b36eb Add tests for hm:t#push failures 2009-08-11 02:37:04 +01:00
Bryan Helmkamp
d15ddf04ec Allow delegating to nil, because the method might actually exist on it 2009-08-10 18:48:38 -05:00
Pratik Naik
d0f891ae02 Rewrite hm:t#create tests using assert_no_difference and assert_difference 2009-08-10 21:30:44 +01:00
Pratik Naik
ad28e0037b Remove unnecessary scoping for creating hm:t join record 2009-08-10 21:20:01 +01:00
Pratik Naik
50b83984f1 Remove unnecessary scoping and validation checks from hm:t#create 2009-08-10 21:06:49 +01:00
Pratik Naik
d9c4087a9e Unify hm:t#create and create! implementation 2009-08-10 21:02:06 +01:00
Joshua Peek
f97dae5ebe Extract common dirty tracking methods in AMo 2009-08-10 13:51:48 -05:00
Joshua Peek
391f978acd AMo overrides alias_attribute and manages aliasing all known attribute method matchers 2009-08-10 11:58:44 -05:00