Commit 8553413dd92448dcc580ef59b19035f4a68be99a

Authored by AntonioTerceiro
1 parent 19ac13ef

ActionItem23: using strings instead of symbols



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1131 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/rss_feed.rb
... ... @@ -31,7 +31,7 @@ class RssFeed < Article
31 31 def include=(value)
32 32 settings[:include] = value
33 33 end
34   - validates_inclusion_of :include, :in => [ :all, :parent_and_children ], :if => :include
  34 + validates_inclusion_of :include, :in => [ 'all', 'parent_and_children' ], :if => :include
35 35  
36 36 # determinates what to include in the feed as items' description. Possible
37 37 # values are +:body+ (default) and +:abstract+.
... ... @@ -41,7 +41,7 @@ class RssFeed < Article
41 41 def feed_item_description=(value)
42 42 settings[:feed_item_description] = value
43 43 end
44   - validates_inclusion_of :feed_item_description, :in => [ :body, :abstract ], :if => :feed_item_description
  44 + validates_inclusion_of :feed_item_description, :in => [ 'body', 'abstract' ], :if => :feed_item_description
45 45  
46 46 # TODO
47 47 def to_html
... ... @@ -55,7 +55,7 @@ class RssFeed < Article
55 55 # FIXME feed real data into the RSS feed
56 56 def data
57 57 articles =
58   - if (self.include == :parent_and_children) && self.parent
  58 + if (self.include == 'parent_and_children') && self.parent
59 59 self.parent.map_traversal
60 60 else
61 61 profile.recent_documents(self.limit || 10)
... ... @@ -76,7 +76,7 @@ class RssFeed < Article
76 76 unless self == article
77 77 xml.item do
78 78 xml.title(article.name)
79   - if self.feed_item_description == :body
  79 + if self.feed_item_description == 'body'
80 80 xml.description(article.body)
81 81 else
82 82 xml.description(article.abstract)
... ...
test/unit/rss_feed_test.rb
... ... @@ -11,11 +11,11 @@ class RssFeedTest < Test::Unit::TestCase
11 11 assert_kind_of Hash, feed.body
12 12  
13 13 feed.body = {
14   - :feed_item_description => :abstract,
15   - :search => :parent_and_children,
  14 + :feed_item_description => 'abstract',
  15 + :search => 'parent_and_children',
16 16 }
17 17 feed.valid?
18   - assert !feed.errors.invalid?(:body)
  18 + assert !feed.errors.invalid?('body')
19 19 end
20 20  
21 21 should 'alias body as "settings"' do
... ... @@ -64,7 +64,7 @@ class RssFeedTest < Test::Unit::TestCase
64 64  
65 65 should 'be able to choose to put abstract or entire body on feed' do
66 66 profile = create_user('testuser').person
67   - a1 = profile.articles.build(:name => 'article 1', :abstract => 'my abstract', :body => 'my text'); a1.save!
  67 + a1 = profile.articles.build(:name => 'article 1', 'abstract' => 'my abstract', 'body' => 'my text'); a1.save!
68 68  
69 69 feed = RssFeed.new(:name => 'feed')
70 70 feed.profile = profile
... ... @@ -74,7 +74,7 @@ class RssFeedTest < Test::Unit::TestCase
74 74 assert_match /<description>my abstract<\/description>/, rss
75 75 assert_no_match /<description>my text<\/description>/, rss
76 76  
77   - feed.feed_item_description = :body
  77 + feed.feed_item_description = 'body'
78 78 rss = feed.data
79 79 assert_match /<description>my text<\/description>/, rss
80 80 assert_no_match /<description>my abstract<\/description>/, rss
... ... @@ -93,7 +93,7 @@ class RssFeedTest &lt; Test::Unit::TestCase
93 93 feed = RssFeed.new(:name => 'feed')
94 94 feed.parent = a3
95 95 feed.profile = profile
96   - feed.include = :parent_and_children
  96 + feed.include = 'parent_and_children'
97 97 feed.save!
98 98  
99 99 rss = feed.data
... ... @@ -134,32 +134,32 @@ class RssFeedTest &lt; Test::Unit::TestCase
134 134 assert !feed.errors.invalid?(:limit)
135 135 end
136 136  
137   - should 'allow only :parent_and_children and :all as include setting' do
  137 + should 'allow only parent_and_children and all as include setting' do
138 138 feed = RssFeed.new
139 139 feed.include = :something_else
140 140 feed.valid?
141 141 assert feed.errors.invalid?(:include)
142 142  
143   - feed.include = :parent_and_children
  143 + feed.include = 'parent_and_children'
144 144 feed.valid?
145 145 assert !feed.errors.invalid?(:include)
146 146  
147   - feed.include = :all
  147 + feed.include = 'all'
148 148 feed.valid?
149 149 assert !feed.errors.invalid?(:include)
150 150 end
151 151  
152   - should 'allow only :body and :abstract as feed_item_description' do
  152 + should 'allow only body and abstract as feed_item_description' do
153 153 feed = RssFeed.new
154 154 feed.feed_item_description = :something_else
155 155 feed.valid?
156 156 assert feed.errors.invalid?(:feed_item_description)
157 157  
158   - feed.feed_item_description = :body
  158 + feed.feed_item_description = 'body'
159 159 feed.valid?
160 160 assert !feed.errors.invalid?(:feed_item_description)
161 161  
162   - feed.feed_item_description = :abstract
  162 + feed.feed_item_description = 'abstract'
163 163 feed.valid?
164 164 assert !feed.errors.invalid?(:feed_item_description)
165 165 end
... ...