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