Commit Graph

41818 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
38fcee3871 Fix test for cache_key + touched
Ensure the child can actually be touched. The `Bulb` model has no
timestamp column, thus trying to touch it would return `nil`.
2014-01-16 09:05:55 -02:00
Piotr Sarnacki
fbab7b2acc Revert "methods are defined right after the module_eval, so we don't need to do"
This change breaks tests in activesupport/test/core_ext/module_test.rb:

* test_delegation_exception_backtrace
* test_delegation_exception_backtrace_with_allow_nil

This reverts commit 0167765e3f84260522bc2f32d926c1f5dd44957c.
2014-01-16 10:45:53 +01:00
Piotr Sarnacki
2e0f9ed76e Revert "Don't remove trailing slash from PATH_INFO for mounted apps"
The revert is needed because of a regression described in #13369, routes
with trailing slash are no longer recognized properly.

This reverts commit 50311f1391ddd8e0349d74eb57f04b7e0045a27d.
2014-01-16 10:13:51 +01:00
Piotr Sarnacki
73d8a90bee Add failing test for #13369
After introducing 50311f1 a regression was introduced: routes with
trailing slash are no longer recognized properly. This commit provides a
failing test for this situation.
2014-01-16 10:13:40 +01:00
Yves Senn
2a0ba918c4 Merge branch 'fix_order_dependent_tests_in_active_record_suite'
This gets the whole Active Record suite working without calling
`self.i_suck_and_my_tests_are_order_dependent!` on `ActiveSupport::TestCase`.

Note that the test files themselves still run in order. This means
that only order dependencies within a single test file were addressed.
2014-01-16 10:05:30 +01:00
Yves Senn
6eab530429 reset column information after fiddling with Encoding.default_internal
This solves order depndent problems in `base_test.rb`. The leaked column
information crashed test cases using the `Weird` class later on:

```
  2) Error:
BasicsTest#test_group_weirds_by_from:
SyntaxError: /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape
... attribute_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *arg...
...                               ^
/Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape
...te_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args)
...                               ^
/Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape
...e_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args)
...                               ^
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:385:in `module_eval'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:385:in `define_proxy_call'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:294:in `block in define_attribute_method'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:285:in `each'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:285:in `define_attribute_method'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `block in define_attribute_methods'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `each'
    /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `define_attribute_methods'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:72:in `block in define_attribute_methods'
    /Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/mutex_m.rb:73:in `synchronize'
    /Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/mutex_m.rb:73:in `mu_synchronize'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:69:in `define_attribute_methods'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:174:in `method_missing'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:45:in `public_send'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `each'
    /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
    /Users/senny/Projects/rails/activerecord/lib/active_record/core.rb:458:in `init_attributes'
    /Users/senny/Projects/rails/activerecord/lib/active_record/core.rb:191:in `initialize'
    /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:30:in `new'
    /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:30:in `new'
    /Users/senny/Projects/rails/activerecord/lib/active_record/persistence.rb:33:in `create'
    test/cases/base_test.rb:646:in `test_group_weirds_by_from'
```
2014-01-16 09:34:49 +01:00
Yves Senn
fca8b0318e we have with_env_tz as global test helper. Remove duplicate. 2014-01-16 09:34:49 +01:00
Yves Senn
a713900839 isolate class attribute assignment in migration_test.rb
This makes the tests inside `migration_test.rb` order independent.
The assignments to `Reminder.table_name_prefix` and `Reminder.table_name_suffix`
previously leaked and had impact on following test cases.

This patch isolates the assignments on a throw-away subclass.
2014-01-16 09:33:45 +01:00
Yves Senn
f00524375d use teardown for cleanup, not setup.
This solves order dependent issues where the last test
leaked the query cache state. This resulted in the following error:

```
QueryCacheExpiryTest#test_cache_is_expired_by_habtm_delete [test/cases/query_cache_test.rb:275]:
not all expectations were satisfied
unsatisfied expectations:
- expected exactly twice, invoked once: #<ActiveRecord::ConnectionAdapters::SQLite3Adapter:0x7f93e0c65838>.clear_query_cache(any_parameters)
```
2014-01-16 09:33:45 +01:00
Yves Senn
8e1735e26c tests without transactional fixtures need to cleanup afterwards.
This fixes test order issues.
2014-01-16 09:33:45 +01:00
Yves Senn
a6512cbd6c no need to return skip in tests. skip is enough. 2014-01-16 09:33:45 +01:00
Aaron Patterson
0167765e3f methods are defined right after the module_eval, so we don't need to do
any line number maths
2014-01-15 16:07:12 -08:00
Carlos Antonio da Silva
f2f723bca9 Get rid of unused TransactionError constant
This has been added 9 years ago in
a677da209b16f43198b3485dda89dce862fb9bfb, and removed 6 years ago in
38f8252e2d0a109d1b833d6b289cd989e7bfffe4.
2014-01-15 21:15:26 -02:00
Carlos Antonio da Silva
885f3ae390 Avoid converting :on option to array twice when defining commit/rollback callbacks 2014-01-15 21:10:23 -02:00
Carlos Antonio da Silva
1c88b363a3 Unify changelog entries about single quotes [ci skip] 2014-01-15 19:26:00 -02:00
Carlos Antonio da Silva
b59204dba4 Merge pull request #13713 from chulkilee/use-single-quotes
Use single quotes in generated files
2014-01-15 13:24:56 -08:00
Aaron Patterson
8d146c8bec rm dup code
e64a83cdbd/activerecord/test/cases/relation/merging_test.rb (L80-91)
2014-01-14 17:47:10 -08:00
Aaron Patterson
3204bbf879 directly create the ARel AST
rather than allocating a new Relation, just make the AST directly
2014-01-14 16:46:26 -08:00
Godfrey Chan
e64a83cdbd Updated comment to mention the enum mapping class method [ci skip] 2014-01-14 15:41:44 -08:00
Aaron Patterson
ce95fb2991 "string" isn't a valid column type for ActiveRecord
Conflicts:
	activerecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb
2014-01-14 14:01:10 -08:00
Chulki Lee
1ab6c656d6 Use single quotes in generated files 2014-01-14 11:13:42 -08:00
Yves Senn
b23330745b don't establish a new connection when testing with sqlite3_mem.
This fixes broken `rake test_sqlite3_mem` suite for Active Record.
The problem is that that the old database with the schema is lost
when establishing a new connection. Upon reconnting we are left
with a blank database and tests down the line start failing.
2014-01-14 18:03:31 +01:00
Yves Senn
93b38d54df Merge pull request #13350 from ccutrer/sqlite-partial-indexes
sqlite >= 3.8.0 supports partial indexes
2014-01-14 07:58:06 -08:00
Cody Cutrer
547ed45633 sqlite >= 3.8.0 supports partial indexes 2014-01-14 08:53:32 -07:00
Andrew White
8a60f479b0 Merge pull request #13710 from ujjwalt/hotfix/sti
Active Record's subclass_from_attributes shouldn't assume :type is for STI unless there is a type column.
2014-01-14 07:05:54 -08:00
Ujjwal Thaakar
e8d1d84837
Don't try to get the subclass if the inheritance column doesn't exist
The `subclass_from_attrs` method is called even if the column specified by
the `inheritance_column` setting doesn't exist. This prevents setting associations
via the attributes hash if the association name clashes with the value of the setting,
typically `:type`. This worked previously in Rails 3.2.
2014-01-14 18:53:45 +05:30
Godfrey Chan
b242b2dbe7 Enum mappings are now exposed via class methods instead of constants.
Example:

    class Conversation < ActiveRecord::Base
      enum status: [ :active, :archived ]
    end

Before:

    Conversation::STATUS # => { "active" => 0, "archived" => 1 }

After:

    Conversation.statuses # => { "active" => 0, "archived" => 1 }
2014-01-14 04:00:34 -08:00
Carlos Antonio da Silva
028029c1b6 Merge pull request #13705 from mess110/controller_generator_route_quotes
Single quotes for controller generated routes. This is more consistent with all other Rails generated code.
2014-01-14 02:13:28 -08:00
Yves Senn
c2a6fc42d2 Merge pull request #13706 from prathamesh-sonpatki/issue-13125
Fix fields_for documentation with index option [ci skip]
2014-01-14 01:16:34 -08:00
Prathamesh Sonpatki
3cf5d2b75b Fix fields_for documentation with index option [ci skip]
- fields_for documentation with index option was wrong.
- It does not work with passing model as it is.
- Changed the example by passing id of the address object.
- Fixes #13125.
2014-01-14 14:38:07 +05:30
Yves Senn
d901699aca Merge pull request #13709 from akshay-vishnoi/typo
[ci skip] Grammar correction
2014-01-14 00:29:32 -08:00
Yves Senn
66f3d5bd5a quick pass through Active Record CHANGELOG. [ci skip] 2014-01-14 09:19:37 +01:00
Akshay Vishnoi
a71a8e2a35 [ci skip] Grammar correction 2014-01-14 13:43:47 +05:30
Yves Senn
f6ca00bd43 Merge pull request #13669 from chulkilee/name-error-name
Set NameError#name
2014-01-14 00:12:54 -08:00
Damien Mathieu
58730361b3 Merge pull request #13707 from udaykadaboina/docModification
[ci skip] Added alias to CSRF
2014-01-13 23:48:38 -08:00
Cristian Mircea Messel
9cdc7c0614 single quotes for controller generated routes
Write routes in route.rb with single quotes

    get 'welcome/index'

instead of

    get "welcome/index"
2014-01-14 09:31:51 +02:00
Uday Kadaboina
ad04c2e0b5 [ci skip] Added alias to CSRF 2014-01-14 01:31:23 -05:00
Aaron Patterson
f1764a2de1 unscope should remove bind values associated with the where 2014-01-13 16:15:20 -08:00
Aaron Patterson
1e2d7c2de2 reverse_order_value= is not private, so no need to send
It's not public API, but is not private scoped.
2014-01-13 16:10:57 -08:00
Aaron Patterson
81d10b9add avoid more dynamic symbols 2014-01-13 15:25:47 -08:00
Aaron Patterson
492bad71f3 no need to to_sym 2014-01-13 15:11:19 -08:00
Rafael Mendonça França
7e02effa7a Merge pull request #13704 from waynn/patch-4
"serie" => "series"
2014-01-13 15:10:45 -08:00
Aaron Patterson
d220e8add9 recover from test runs that leave the database in a bad state 2014-01-13 15:02:28 -08:00
Xavier Noria
e992cd4d91 updates screenshot data [ci skip] 2014-01-13 23:32:04 +01:00
Waynn Lue
fd68adc8a9 "serie" => "series" 2014-01-13 14:23:58 -08:00
Xavier Noria
7524a9166c revises a few things in the getting started guide [ci skip]
More to come.
2014-01-13 23:11:44 +01:00
Chulki Lee
bea44cbaa4 Set NameError#name 2014-01-13 12:47:14 -08:00
Rafael Mendonça França
8b70319c27 Merge pull request #13703 from schneems/schneems/rail-secrets-key
Favor canonical environment variables for secrets
2014-01-13 12:33:04 -08:00
schneems
b9095ec95c Favor canonical environment variables for secrets
Prefixing an environment variable with `RAILS_` should be used when there is otherwise a conflict, such as `RAILS_ENV` or if it is being used for a very Rails specific value.

If we remove the prefix of `RAILS_` in the case of `RAILS_SECRET_KEY_BASE` then we can push for a pseudo standard among other frameworks that will accept a common environment key `SECRET_KEY_BASE` to keep your app secure. This is beneficial for containerized deployments such as docker, Heroku, etc. So that the container need to know one less thing about your app (it can just set it no-matter what language or framework you are using). 

This change also allows the defaults to be consistent with the way the secret key is accessed so `secrets.secret_key_base` is aliased to `SECRET_KEY_BASE` instead of `RAILS_SECRET_KEY_BASE`.
2014-01-13 14:31:43 -06:00
Rafael Mendonça França
fe24a383d1 Merge pull request #13702 from kuldeepaggarwal/docs-fix
removed extra comma [ci skip]
2014-01-13 11:52:01 -08:00