Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 1625 Bytes
1 | require "cases/helper" |
2 | require 'models/contact' |
3 | |
4 | class SerializationTest < ActiveRecord::TestCase |
5 | FORMATS = [ :xml, :json ] |
6 | |
7 | def setup |
8 | @contact_attributes = { |
9 | :name => 'aaron stack', |
10 | :age => 25, |
11 | :avatar => 'binarydata', |
12 | :created_at => Time.utc(2006, 8, 1), |
13 | :awesome => false, |
14 | :preferences => { :gem => '<strong>ruby</strong>' } |
15 | } |
16 | |
17 | @contact = Contact.new(@contact_attributes) |
18 | end |
19 | |
20 | def test_serialize_should_be_reversible |
21 | for format in FORMATS |
22 | @serialized = Contact.new.send("to_#{format}") |
23 | contact = Contact.new.send("from_#{format}", @serialized) |
24 | |
25 | assert_equal @contact_attributes.keys.collect(&:to_s).sort, contact.attributes.keys.collect(&:to_s).sort, "For #{format}" |
26 | end |
27 | end |
28 | |
29 | def test_serialize_should_allow_attribute_only_filtering |
30 | for format in FORMATS |
31 | @serialized = Contact.new(@contact_attributes).send("to_#{format}", :only => [ :age, :name ]) |
32 | contact = Contact.new.send("from_#{format}", @serialized) |
33 | assert_equal @contact_attributes[:name], contact.name, "For #{format}" |
34 | assert_nil contact.avatar, "For #{format}" |
35 | end |
36 | end |
37 | |
38 | def test_serialize_should_allow_attribute_except_filtering |
39 | for format in FORMATS |
40 | @serialized = Contact.new(@contact_attributes).send("to_#{format}", :except => [ :age, :name ]) |
41 | contact = Contact.new.send("from_#{format}", @serialized) |
42 | assert_nil contact.name, "For #{format}" |
43 | assert_nil contact.age, "For #{format}" |
44 | assert_equal @contact_attributes[:awesome], contact.awesome, "For #{format}" |
45 | end |
46 | end |
47 | end |