Commit Graph

23 Commits

Author SHA1 Message Date
Yukio Mizuta
e0bc5b4da1 Update prefix and allow suffix options for store accessors 2018-06-12 07:10:09 -07:00
Tan Huynh
3f297be72b Add custom prefix to ActiveRecord::Store accessors
Add a prefix option to ActiveRecord::Store.store_accessor and
ActiveRecord::Store.store. This option allows stores to have identical keys
with different accessors.
2018-03-23 08:01:46 +07:00
Kir Shatrov
831be98f9a Use frozen-string-literal in ActiveRecord 2017-07-19 22:27:07 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Xavier Noria
d22e522179 modernizes hash syntax in activerecord 2016-08-06 19:37:57 +02:00
Xavier Noria
9617db2078 applies new string literal convention in activerecord/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:26:53 +02:00
Sean Griffin
b3fdf9c596 Add line endings to files which are missing them
These files get modified whenever someone uses a tool like `sed`. Let's
just get this over with in one commit so it'd not adding diff noise to
something else.
2015-02-17 13:28:06 -07:00
Vipul A M
4ae59ebee8 Fixes #18492
- Add check for not deleting previously created fixtures, to overcome sti fixtures from multiple files
- Added fixtures and fixtures test to verify the same

- Fixed wrong fixtures duplicating data insertion in same table
2015-01-14 21:36:58 +05:30
Matthias Zirnstein
2a0fdde380 Remove warnings in test suite
lib/active_record/store.rb:79: warning: method redefined; discarding old color=
lib/active_record/store.rb:79: warning: previous definition of color= was here
lib/active_record/store.rb:83: warning: method redefined; discarding old color
lib/active_record/store.rb:83: warning: previous definition of color was here
2014-01-06 16:40:32 +01:00
Thales Oliveira
901a0c8b4a Fix: ActiveRecord::Store TypeError conversion when using YAML coder
Renaming the test accordingly to its behaviour

Adding 'Fixes' statement to changelog

Improving tests legibility & changelog

Undoing mistakenly removed empty line & further improving changelog
2014-01-06 11:36:19 -02:00
Sergey Nartimov
9dfef5a46b define Active Record Store accessors in a module
Allow store accessors to be overrided like other attribute methods,
e.g.:

    class User < ActiveRecord::Base
      store :settings, accessors: [ :color, :homepage ], coder: JSON

      def color
        super || 'red'
      end
    end
2013-02-11 17:00:55 +03:00
Andrew White
1b75b94de6 Remove warning by using a custom coder
The native JSON library bypasses the `to_json` overrides in
active_support/core_ext/object/to_json.rb by calling its native
implementation directly. However `ActiveRecord::Store` uses a
HWIA so `JSON.dump` will call our `to_json` instead with a
`State` object for options rather than a `Hash`. This generates
a warning when the `:encoding`, `:only` & `:except` keys are
accessed in `Hash#as_json` because the `State` object delegates
unknown keys to `instance_variable_get` in its `:[]` method.

Workaround this warning in the test by using a custom coder that
calls `ActiveSupport::JSON.encode` directly.
2013-01-23 14:54:56 +00:00
kennyj
df08271f9c fix warning: method redefined 2012-10-02 13:32:54 -03:00
Matt Jones
46873aeded refactor store_accessor 2012-09-13 10:12:11 -04:00
Matt Jones
20f943ffd8 correctly flag changed attributes in AR::Store, combine multiple calls to store_accessor 2012-09-05 11:01:26 -04:00
Andrey Voronkov
3c0bf0435c Custom coders support for ActiveRecord::Store. JSON, YAML, Marshal can be used out of the box. 2012-05-09 19:20:14 +04:00
Jeremy Walker
58d10e2012 Allow store to be a not null column. 2012-02-02 18:57:15 +00:00
Alexey Muranov
6468ff4197 Test fixtures with custom model and table names
Test using fixtures with random names and model names, that is not following naming conventions but using set_fixture_class instead.

It is expected that the table name be defined in the model, but this is not explicitly tested here.  This will need to be fixed.
2011-12-30 10:34:01 +01:00
Jeremy Kemper
0a9b6de4d2 Tests gotta run in 1.8 too 2011-10-13 15:54:53 -07:00
David Heinemeier Hansson
85b64f98d1 Added ActiveRecord::Base.store for declaring simple single-column key/value stores [DHH] 2011-10-13 16:24:22 -05:00
Andrew White
8ec085bf18 Support fixtures for namespaced models [#2965 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-25 16:04:38 +02:00