Commit e4a49c3b743b2e07c5f15ca100c34e8ffdb0f9eb
1 parent
132c1fdd
Exists in
master
and in
28 other branches
ActionItem23: refactoring: transformed settings in attributes
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1129 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
28 additions
and
7 deletions
Show diff stats
app/models/rss_feed.rb
... | ... | @@ -8,6 +8,27 @@ class RssFeed < Article |
8 | 8 | end |
9 | 9 | alias :settings :body |
10 | 10 | |
11 | + def limit | |
12 | + settings[:limit] | |
13 | + end | |
14 | + def limit=(value) | |
15 | + settings[:limit] = value | |
16 | + end | |
17 | + | |
18 | + def include | |
19 | + settings[:include] | |
20 | + end | |
21 | + def include=(value) | |
22 | + settings[:include] = value | |
23 | + end | |
24 | + | |
25 | + def feed_item_description | |
26 | + settings[:feed_item_description] | |
27 | + end | |
28 | + def feed_item_description=(value) | |
29 | + settings[:feed_item_description] = value | |
30 | + end | |
31 | + | |
11 | 32 | # TODO |
12 | 33 | def to_html |
13 | 34 | end |
... | ... | @@ -20,10 +41,10 @@ class RssFeed < Article |
20 | 41 | # FIXME feed real data into the RSS feed |
21 | 42 | def data |
22 | 43 | articles = |
23 | - if (self.settings[:include] == :parent_and_children) && self.parent | |
44 | + if (self.include == :parent_and_children) && self.parent | |
24 | 45 | self.parent.map_traversal |
25 | 46 | else |
26 | - profile.recent_documents(self.settings[:limit] || 10) | |
47 | + profile.recent_documents(self.limit || 10) | |
27 | 48 | end |
28 | 49 | |
29 | 50 | |
... | ... | @@ -41,7 +62,7 @@ class RssFeed < Article |
41 | 62 | unless self == article |
42 | 63 | xml.item do |
43 | 64 | xml.title(article.name) |
44 | - if self.settings[:description] == :body | |
65 | + if self.feed_item_description == :body | |
45 | 66 | xml.description(article.body) |
46 | 67 | else |
47 | 68 | xml.description(article.abstract) | ... | ... |
test/unit/rss_feed_test.rb
... | ... | @@ -11,7 +11,7 @@ class RssFeedTest < Test::Unit::TestCase |
11 | 11 | assert_kind_of Hash, feed.body |
12 | 12 | |
13 | 13 | feed.body = { |
14 | - :description => :abstract, | |
14 | + :feed_item_description => :abstract, | |
15 | 15 | :search => :parent_and_children, |
16 | 16 | } |
17 | 17 | feed.valid? |
... | ... | @@ -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.settings[: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 < Test::Unit::TestCase |
93 | 93 | feed = RssFeed.new(:name => 'feed') |
94 | 94 | feed.parent = a3 |
95 | 95 | feed.profile = profile |
96 | - feed.settings[:include] = :parent_and_children | |
96 | + feed.include = :parent_and_children | |
97 | 97 | feed.save! |
98 | 98 | |
99 | 99 | rss = feed.data |
... | ... | @@ -119,7 +119,7 @@ class RssFeedTest < Test::Unit::TestCase |
119 | 119 | feed.profile.expects(:recent_documents).with(10).returns([]).once |
120 | 120 | feed.data |
121 | 121 | |
122 | - feed.settings[:limit] = 5 | |
122 | + feed.limit = 5 | |
123 | 123 | feed.profile.expects(:recent_documents).with(5).returns([]).once |
124 | 124 | feed.data |
125 | 125 | end | ... | ... |