Commit 2f9962a53239a89e624582828c9c1961be7c5cbf
1 parent
bdd5ef3e
Exists in
master
and in
29 other branches
relevant_content: remove trailing spaces
Showing
5 changed files
with
130 additions
and
130 deletions
Show diff stats
plugins/relevant_content/lib/ext/article.rb
1 | 1 | require_dependency 'article' |
2 | 2 | |
3 | 3 | class Article |
4 | - | |
4 | + | |
5 | 5 | named_scope :relevant_content, :conditions => ["(articles.type != 'UploadedFile' and articles.type != 'Blog' and articles.type != 'RssFeed') OR articles.type is NULL"] |
6 | 6 | |
7 | 7 | def self.most_accessed(owner, limit = nil) |
8 | - if owner.kind_of?(Environment) | |
8 | + if owner.kind_of?(Environment) | |
9 | 9 | result = Article.relevant_content.find( |
10 | 10 | :all, |
11 | 11 | :order => 'hits desc', |
12 | 12 | :limit => limit, |
13 | - :conditions => ["hits > 0"] | |
13 | + :conditions => ["hits > 0"] | |
14 | 14 | ) |
15 | 15 | result.paginate({:page => 1, :per_page => limit}) |
16 | 16 | else |
17 | 17 | #Owner is a profile |
18 | 18 | result = Article.relevant_content.find( |
19 | - :all, | |
19 | + :all, | |
20 | 20 | :order => 'hits desc', |
21 | 21 | :limit => limit, |
22 | - :conditions => ["profile_id = ? and hits > 0", owner.id] | |
22 | + :conditions => ["profile_id = ? and hits > 0", owner.id] | |
23 | 23 | ) |
24 | 24 | result.paginate({:page => 1, :per_page => limit}) |
25 | - end | |
25 | + end | |
26 | 26 | end |
27 | 27 | |
28 | 28 | def self.most_commented_relevant_content(owner, limit) |
29 | - | |
30 | - if owner.kind_of?(Environment) | |
29 | + | |
30 | + if owner.kind_of?(Environment) | |
31 | 31 | result = Article.relevant_content.find( |
32 | 32 | :all, |
33 | 33 | :order => 'comments_count desc', |
34 | 34 | :limit => limit, |
35 | - :conditions => ["comments_count > 0"] | |
35 | + :conditions => ["comments_count > 0"] | |
36 | 36 | ) |
37 | 37 | result.paginate({:page => 1, :per_page => limit}) |
38 | 38 | else |
39 | 39 | #Owner is a profile |
40 | 40 | result = Article.relevant_content.find( |
41 | - :all, | |
41 | + :all, | |
42 | 42 | :order => 'comments_count desc', |
43 | 43 | :limit => limit, |
44 | - :conditions => ["profile_id = ? and comments_count > 0", owner.id] | |
44 | + :conditions => ["profile_id = ? and comments_count > 0", owner.id] | |
45 | 45 | ) |
46 | 46 | result.paginate({:page => 1, :per_page => limit}) |
47 | - end | |
48 | - end | |
49 | - | |
47 | + end | |
48 | + end | |
49 | + | |
50 | 50 | def self.articles_columns |
51 | 51 | Article.column_names.map {|c| "articles.#{c}"} .join(",") |
52 | 52 | end |
53 | - | |
53 | + | |
54 | 54 | def self.more_positive_votes(owner, limit = nil) |
55 | - if owner.kind_of?(Environment) | |
55 | + if owner.kind_of?(Environment) | |
56 | 56 | result = Article.find( |
57 | 57 | :all, |
58 | - :select => articles_columns, | |
58 | + :select => articles_columns, | |
59 | 59 | :order => 'sum(vote) desc', |
60 | 60 | :group => 'voteable_id, ' + articles_columns, |
61 | 61 | :limit => limit, |
62 | - :having => ['sum(vote) > 0'], | |
63 | - :conditions => {'votes.voteable_type' => 'Article'}, | |
62 | + :having => ['sum(vote) > 0'], | |
63 | + :conditions => {'votes.voteable_type' => 'Article'}, | |
64 | 64 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id' |
65 | - ) | |
65 | + ) | |
66 | 66 | result.paginate({:page => 1, :per_page => limit}) |
67 | 67 | else |
68 | 68 | #Owner is a profile |
69 | 69 | result = Article.find( |
70 | 70 | :all, |
71 | - :select => articles_columns, | |
71 | + :select => articles_columns, | |
72 | 72 | :order => 'sum(vote) desc', |
73 | 73 | :group => 'voteable_id, ' + articles_columns, |
74 | 74 | :limit => limit, |
75 | 75 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
76 | - :having => ['sum(vote) > 0'], | |
77 | - :conditions => ["profile_id = ? and votes.voteable_type = ? ", owner.id, 'Article'] | |
76 | + :having => ['sum(vote) > 0'], | |
77 | + :conditions => ["profile_id = ? and votes.voteable_type = ? ", owner.id, 'Article'] | |
78 | 78 | ) |
79 | 79 | result.paginate({:page => 1, :per_page => limit}) |
80 | 80 | end |
81 | 81 | end |
82 | - | |
82 | + | |
83 | 83 | def self.more_negative_votes(owner, limit = nil) |
84 | - if owner.kind_of?(Environment) | |
84 | + if owner.kind_of?(Environment) | |
85 | 85 | result = Article.find( |
86 | 86 | :all, |
87 | - :select => articles_columns, | |
87 | + :select => articles_columns, | |
88 | 88 | :order => 'sum(vote) asc', |
89 | 89 | :group => 'voteable_id, ' + articles_columns, |
90 | 90 | :limit => limit, |
91 | - :having => ['sum(vote) < 0'], | |
91 | + :having => ['sum(vote) < 0'], | |
92 | 92 | :conditions => {'votes.voteable_type' => 'Article'}, |
93 | - :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id' | |
93 | + :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id' | |
94 | 94 | ) |
95 | 95 | result.paginate({:page => 1, :per_page => limit}) |
96 | 96 | else |
97 | 97 | #Owner is a profile |
98 | 98 | result = Article.find( |
99 | 99 | :all, |
100 | - :select => articles_columns, | |
100 | + :select => articles_columns, | |
101 | 101 | :order => 'sum(vote) asc', |
102 | 102 | :group => 'voteable_id, ' + articles_columns, |
103 | 103 | :limit => limit, |
104 | 104 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
105 | - :having => ['sum(vote) < 0'], | |
106 | - :conditions => ["profile_id = ? and votes.voteable_type = 'Article' ", owner.id] | |
105 | + :having => ['sum(vote) < 0'], | |
106 | + :conditions => ["profile_id = ? and votes.voteable_type = 'Article' ", owner.id] | |
107 | 107 | ) |
108 | 108 | result.paginate({:page => 1, :per_page => limit}) |
109 | 109 | end |
110 | 110 | end |
111 | - | |
111 | + | |
112 | 112 | def self.most_liked(owner, limit = nil) |
113 | - if owner.kind_of?(Environment) | |
113 | + if owner.kind_of?(Environment) | |
114 | 114 | result = Article.find( |
115 | 115 | :all, |
116 | - :select => articles_columns, | |
116 | + :select => articles_columns, | |
117 | 117 | :order => 'count(voteable_id) desc', |
118 | 118 | :group => 'voteable_id, ' + articles_columns, |
119 | 119 | :limit => limit, |
120 | 120 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
121 | 121 | :conditions => ["votes.voteable_type = 'Article' and vote > 0"] |
122 | - ) | |
122 | + ) | |
123 | 123 | result.paginate({:page => 1, :per_page => limit}) |
124 | 124 | else |
125 | 125 | #Owner is a profile |
126 | 126 | result = Article.find( |
127 | 127 | :all, |
128 | - :select => articles_columns, | |
128 | + :select => articles_columns, | |
129 | 129 | :order => 'count(voteable_id) desc', |
130 | 130 | :group => 'voteable_id, ' + articles_columns, |
131 | 131 | :limit => limit, |
132 | 132 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
133 | - :conditions => ["votes.voteable_type = 'Article' and vote > 0 and profile_id = ? ", owner.id] | |
133 | + :conditions => ["votes.voteable_type = 'Article' and vote > 0 and profile_id = ? ", owner.id] | |
134 | 134 | ) |
135 | 135 | result.paginate({:page => 1, :per_page => limit}) |
136 | 136 | end |
137 | 137 | end |
138 | - | |
138 | + | |
139 | 139 | def self.most_disliked(owner, limit = nil) |
140 | - if owner.kind_of?(Environment) | |
140 | + if owner.kind_of?(Environment) | |
141 | 141 | result = Article.find( |
142 | 142 | :all, |
143 | 143 | :order => 'count(voteable_id) desc', |
144 | 144 | :group => 'voteable_id, ' + articles_columns, |
145 | 145 | :limit => limit, |
146 | 146 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
147 | - :conditions => ["votes.voteable_type = 'Article' and vote < 0"] | |
147 | + :conditions => ["votes.voteable_type = 'Article' and vote < 0"] | |
148 | 148 | ) |
149 | 149 | result.paginate({:page => 1, :per_page => limit}) |
150 | 150 | else |
151 | 151 | #Owner is a profile |
152 | 152 | result = Article.find( |
153 | - :all, | |
153 | + :all, | |
154 | 154 | :order => 'count(voteable_id) desc', |
155 | 155 | :group => 'voteable_id, ' + articles_columns, |
156 | 156 | :limit => limit, |
157 | 157 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
158 | - :conditions => ["votes.voteable_type = 'Article' and vote < 0 and profile_id = ? ", owner.id] | |
158 | + :conditions => ["votes.voteable_type = 'Article' and vote < 0 and profile_id = ? ", owner.id] | |
159 | 159 | ) |
160 | 160 | result.paginate({:page => 1, :per_page => limit}) |
161 | 161 | end |
162 | 162 | end |
163 | - | |
163 | + | |
164 | 164 | def self.most_voted(owner, limit = nil) |
165 | - if owner.kind_of?(Environment) | |
165 | + if owner.kind_of?(Environment) | |
166 | 166 | result = Article.find( |
167 | 167 | :all, |
168 | - :select => articles_columns, | |
168 | + :select => articles_columns, | |
169 | 169 | :order => 'count(voteable_id) desc', |
170 | 170 | :group => 'voteable_id, ' + articles_columns, |
171 | 171 | :limit => limit, |
172 | 172 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
173 | 173 | :conditions => ["votes.voteable_type = 'Article'"] |
174 | - ) | |
174 | + ) | |
175 | 175 | result.paginate({:page => 1, :per_page => limit}) |
176 | 176 | else |
177 | 177 | #Owner is a profile |
178 | 178 | result = Article.find( |
179 | 179 | :all, |
180 | - :select => articles_columns, | |
180 | + :select => articles_columns, | |
181 | 181 | :order => 'count(voteable_id) desc', |
182 | 182 | :group => 'voteable_id, ' + articles_columns, |
183 | 183 | :limit => limit, |
184 | 184 | :joins => 'INNER JOIN votes ON articles.id = votes.voteable_id', |
185 | - :conditions => ["votes.voteable_type = 'Article' and profile_id = ? ", owner.id] | |
185 | + :conditions => ["votes.voteable_type = 'Article' and profile_id = ? ", owner.id] | |
186 | 186 | ) |
187 | 187 | result.paginate({:page => 1, :per_page => limit}) |
188 | 188 | end |
189 | 189 | end |
190 | - | |
191 | - | |
192 | - | |
193 | - | |
194 | -end | |
195 | 190 | \ No newline at end of file |
191 | + | |
192 | + | |
193 | + | |
194 | + | |
195 | +end | |
196 | 196 | \ No newline at end of file | ... | ... |
plugins/relevant_content/lib/relevant_content_plugin.rb
plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb
... | ... | @@ -12,80 +12,80 @@ class RelevantContentPlugin::RelevantContentBlock < Block |
12 | 12 | end |
13 | 13 | |
14 | 14 | settings_items :limit, :type => :integer, :default => 5 |
15 | - settings_items :show_most_read, :type => :integer, :default => 1 | |
16 | - settings_items :show_most_commented, :type => :integer, :default => 1 | |
17 | - settings_items :show_most_liked, :type => :integer, :default => 1 | |
18 | - settings_items :show_most_disliked, :type => :integer, :default => 0 | |
19 | - settings_items :show_most_voted, :type => :integer, :default => 1 | |
15 | + settings_items :show_most_read, :type => :integer, :default => 1 | |
16 | + settings_items :show_most_commented, :type => :integer, :default => 1 | |
17 | + settings_items :show_most_liked, :type => :integer, :default => 1 | |
18 | + settings_items :show_most_disliked, :type => :integer, :default => 0 | |
19 | + settings_items :show_most_voted, :type => :integer, :default => 1 | |
20 | 20 | |
21 | 21 | include ActionController::UrlWriter |
22 | 22 | def content(args={}) |
23 | 23 | |
24 | - content = block_title(title) | |
25 | - | |
24 | + content = block_title(title) | |
25 | + | |
26 | 26 | if self.show_most_read != 0 |
27 | - docs = Article.most_accessed(owner, self.limit) | |
28 | - if !docs.blank? | |
27 | + docs = Article.most_accessed(owner, self.limit) | |
28 | + if !docs.blank? | |
29 | 29 | subcontent = "" |
30 | - subcontent += content_tag(:span, _("Most read articles"), :class=>"title mread") + "\n" | |
31 | - subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
32 | - content += content_tag(:div, subcontent, :class=>"block mread") + "\n" | |
33 | - end | |
30 | + subcontent += content_tag(:span, _("Most read articles"), :class=>"title mread") + "\n" | |
31 | + subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
32 | + content += content_tag(:div, subcontent, :class=>"block mread") + "\n" | |
33 | + end | |
34 | 34 | end |
35 | 35 | |
36 | 36 | if self.show_most_commented != 0 |
37 | 37 | docs = Article.most_commented_relevant_content(owner, self.limit) |
38 | - if !docs.blank? | |
39 | - subcontent = "" | |
40 | - subcontent += content_tag(:span, _("Most commented articles"), :class=>"title mcommented") + "\n" | |
41 | - subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
38 | + if !docs.blank? | |
39 | + subcontent = "" | |
40 | + subcontent += content_tag(:span, _("Most commented articles"), :class=>"title mcommented") + "\n" | |
41 | + subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
42 | 42 | content += content_tag(:div, subcontent, :class=>"block mcommented") + "\n" |
43 | 43 | end |
44 | 44 | end |
45 | 45 | |
46 | - if owner.kind_of?(Environment) | |
46 | + if owner.kind_of?(Environment) | |
47 | 47 | env = owner |
48 | 48 | else |
49 | 49 | env = owner.environment |
50 | 50 | end |
51 | - | |
51 | + | |
52 | 52 | if env.plugin_enabled?(VotePlugin) |
53 | 53 | if self.show_most_liked != 0 |
54 | 54 | docs = Article.more_positive_votes(owner, self.limit) |
55 | - if !docs.blank? | |
56 | - subcontent = "" | |
57 | - subcontent += content_tag(:span, _("Most liked articles"), :class=>"title mliked") + "\n" | |
58 | - subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
55 | + if !docs.blank? | |
56 | + subcontent = "" | |
57 | + subcontent += content_tag(:span, _("Most liked articles"), :class=>"title mliked") + "\n" | |
58 | + subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
59 | 59 | content += content_tag(:div, subcontent, :class=>"block mliked") + "\n" |
60 | 60 | end |
61 | 61 | end |
62 | 62 | if self.show_most_disliked != 0 |
63 | 63 | docs = Article.more_negative_votes(owner, self.limit) |
64 | - if !docs.blank? | |
65 | - subcontent = "" | |
66 | - subcontent += content_tag(:span, _("Most disliked articles"), :class=>"title mdisliked") + "\n" | |
67 | - subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
68 | - content += content_tag(:div, subcontent, :class=>"block mdisliked") + "\n" | |
64 | + if !docs.blank? | |
65 | + subcontent = "" | |
66 | + subcontent += content_tag(:span, _("Most disliked articles"), :class=>"title mdisliked") + "\n" | |
67 | + subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
68 | + content += content_tag(:div, subcontent, :class=>"block mdisliked") + "\n" | |
69 | 69 | end |
70 | 70 | end |
71 | - | |
71 | + | |
72 | 72 | if self.show_most_voted != 0 |
73 | 73 | docs = Article.most_voted(owner, self.limit) |
74 | - if !docs.blank? | |
74 | + if !docs.blank? | |
75 | 75 | subcontent = "" |
76 | - subcontent += content_tag(:span, _("Most voted articles"), :class=>"title mvoted") + "\n" | |
77 | - subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
78 | - content += content_tag(:div, subcontent, :class=>"block mvoted") + "\n" | |
76 | + subcontent += content_tag(:span, _("Most voted articles"), :class=>"title mvoted") + "\n" | |
77 | + subcontent += content_tag(:ul, docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | |
78 | + content += content_tag(:div, subcontent, :class=>"block mvoted") + "\n" | |
79 | 79 | end |
80 | - end | |
80 | + end | |
81 | 81 | end |
82 | 82 | return content |
83 | - end | |
84 | - | |
83 | + end | |
84 | + | |
85 | 85 | def timeout |
86 | 86 | 4.hours |
87 | - end | |
88 | - | |
87 | + end | |
88 | + | |
89 | 89 | def self.expire_on |
90 | 90 | { :profile => [:article], :environment => [:article] } |
91 | 91 | end | ... | ... |
plugins/relevant_content/test/unit/relevant_content_block_test.rb
... | ... | @@ -5,10 +5,10 @@ require 'comment_controller' |
5 | 5 | class CommentController; def rescue_action(e) raise e end; end |
6 | 6 | |
7 | 7 | class RelevantContentBlockTest < ActiveSupport::TestCase |
8 | - | |
8 | + | |
9 | 9 | include AuthenticatedTestHelper |
10 | 10 | fixtures :users, :environments |
11 | - | |
11 | + | |
12 | 12 | def setup |
13 | 13 | @controller = CommentController.new |
14 | 14 | @request = ActionController::TestRequest.new |
... | ... | @@ -18,15 +18,15 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
18 | 18 | @environment = @profile.environment |
19 | 19 | end |
20 | 20 | attr_reader :profile, :environment |
21 | - | |
22 | - | |
23 | - | |
21 | + | |
22 | + | |
23 | + | |
24 | 24 | should 'have a default title' do |
25 | 25 | relevant_content_block = RelevantContentPlugin::RelevantContentBlock.new |
26 | 26 | block = Block.new |
27 | 27 | assert_not_equal block.default_title, relevant_content_block.default_title |
28 | 28 | end |
29 | - | |
29 | + | |
30 | 30 | should 'have a help tooltip' do |
31 | 31 | relevant_content_block = RelevantContentPlugin::RelevantContentBlock.new |
32 | 32 | block = Block.new |
... | ... | @@ -36,7 +36,7 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
36 | 36 | should 'describe itself' do |
37 | 37 | assert_not_equal Block.description, RelevantContentPlugin::RelevantContentBlock.description |
38 | 38 | end |
39 | - | |
39 | + | |
40 | 40 | should 'is editable' do |
41 | 41 | block = RelevantContentPlugin::RelevantContentBlock.new |
42 | 42 | assert block.editable? |
... | ... | @@ -51,19 +51,19 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
51 | 51 | Article.most_accessed(Environment.default, 5) |
52 | 52 | } |
53 | 53 | end |
54 | - | |
54 | + | |
55 | 55 | should 'not raise an exception when finding the most commented content' do |
56 | 56 | assert_nothing_raised{ |
57 | 57 | Article.most_commented_relevant_content(Environment.default, 5) |
58 | 58 | } |
59 | 59 | end |
60 | - | |
60 | + | |
61 | 61 | should 'not raise an exception when finding the most liked content' do |
62 | - begin | |
62 | + begin | |
63 | 63 | Environment.default.enable_plugin(:vote) |
64 | 64 | rescue |
65 | - puts "Unable to activate vote plugin" | |
66 | - end | |
65 | + puts "Unable to activate vote plugin" | |
66 | + end | |
67 | 67 | if Environment.default.plugin_enabled?(:vote) |
68 | 68 | assert_nothing_raised{ |
69 | 69 | Article.most_liked(Environment.default, 5) |
... | ... | @@ -72,11 +72,11 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
72 | 72 | end |
73 | 73 | |
74 | 74 | should 'not raise an exception when finding the most disliked content' do |
75 | - begin | |
75 | + begin | |
76 | 76 | Environment.default.enable_plugin(:vote) |
77 | 77 | rescue |
78 | 78 | puts "Unable to activate vote plugin" |
79 | - end | |
79 | + end | |
80 | 80 | if Environment.default.plugin_enabled?(:vote) |
81 | 81 | assert_nothing_raised{ |
82 | 82 | Article.most_disliked(Environment.default, 5) |
... | ... | @@ -84,13 +84,13 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
84 | 84 | end |
85 | 85 | end |
86 | 86 | |
87 | - | |
87 | + | |
88 | 88 | should 'not raise an exception when finding the more positive votes' do |
89 | - begin | |
89 | + begin | |
90 | 90 | Environment.default.enable_plugin(:vote) |
91 | 91 | rescue |
92 | - puts "Unable to activate vote plugin" | |
93 | - end | |
92 | + puts "Unable to activate vote plugin" | |
93 | + end | |
94 | 94 | if Environment.default.plugin_enabled?(:vote) |
95 | 95 | assert_nothing_raised{ |
96 | 96 | Article.more_positive_votes(Environment.default, 5) |
... | ... | @@ -99,18 +99,18 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
99 | 99 | end |
100 | 100 | |
101 | 101 | should 'not raise an exception when finding the most voted' do |
102 | - begin | |
102 | + begin | |
103 | 103 | Environment.default.enable_plugin(:vote) |
104 | 104 | rescue |
105 | 105 | puts "Unable to activate vote plugin" |
106 | - end | |
106 | + end | |
107 | 107 | if Environment.default.plugin_enabled?(:vote) |
108 | 108 | assert_nothing_raised{ |
109 | 109 | Article.most_voted(Environment.default, 5) |
110 | 110 | } |
111 | 111 | end |
112 | 112 | end |
113 | - | |
113 | + | |
114 | 114 | should 'find the most voted' do |
115 | 115 | |
116 | 116 | article = fast_create(Article, {:name=>'2 votes'}) |
... | ... | @@ -118,19 +118,19 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
118 | 118 | person = fast_create(Person) |
119 | 119 | person.vote_for(article) |
120 | 120 | end |
121 | - | |
121 | + | |
122 | 122 | article = fast_create(Article, {:name=>'10 votes'}) |
123 | 123 | for i in 0..10 |
124 | 124 | person = fast_create(Person) |
125 | 125 | person.vote_for(article) |
126 | 126 | end |
127 | - | |
127 | + | |
128 | 128 | article = fast_create(Article, {:name=>'5 votes'}) |
129 | 129 | for i in 0..5 |
130 | 130 | person = fast_create(Person) |
131 | 131 | person.vote_for(article) |
132 | 132 | end |
133 | - | |
133 | + | |
134 | 134 | articles = Article.most_voted(Environment.default, 5) |
135 | 135 | assert_equal '10 votes', articles.first.name |
136 | 136 | assert_equal '2 votes', articles.last.name |
... | ... | @@ -147,7 +147,7 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
147 | 147 | person = fast_create(Person) |
148 | 148 | person.vote_for(article) |
149 | 149 | end |
150 | - | |
150 | + | |
151 | 151 | article = fast_create(Article, {:name=>'10 votes for 5 votes against'}) |
152 | 152 | for i in 0..10 |
153 | 153 | person = fast_create(Person) |
... | ... | @@ -157,7 +157,7 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
157 | 157 | person = fast_create(Person) |
158 | 158 | person.vote_against(article) |
159 | 159 | end |
160 | - | |
160 | + | |
161 | 161 | article = fast_create(Article, {:name=>'2 votes against'}) |
162 | 162 | for i in 0..2 |
163 | 163 | person = fast_create(Person) |
... | ... | @@ -169,12 +169,12 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
169 | 169 | person = fast_create(Person) |
170 | 170 | person.vote_for(article) |
171 | 171 | end |
172 | - | |
172 | + | |
173 | 173 | articles = Article.more_positive_votes(Environment.default, 5) |
174 | 174 | assert_equal '7 votes for', articles.first.name |
175 | 175 | assert_equal '23 votes for 20 votes against', articles.last.name |
176 | 176 | end |
177 | - | |
177 | + | |
178 | 178 | should 'list the most negative' do |
179 | 179 | |
180 | 180 | article = fast_create(Article, {:name=>'23 votes for 29 votes against'}) |
... | ... | @@ -186,7 +186,7 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
186 | 186 | person = fast_create(Person) |
187 | 187 | person.vote_for(article) |
188 | 188 | end |
189 | - | |
189 | + | |
190 | 190 | article = fast_create(Article, {:name=>'10 votes for 15 votes against'}) |
191 | 191 | for i in 0..10 |
192 | 192 | person = fast_create(Person) |
... | ... | @@ -196,7 +196,7 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
196 | 196 | person = fast_create(Person) |
197 | 197 | person.vote_against(article) |
198 | 198 | end |
199 | - | |
199 | + | |
200 | 200 | article = fast_create(Article, {:name=>'2 votes against'}) |
201 | 201 | for i in 0..2 |
202 | 202 | person = fast_create(Person) |
... | ... | @@ -208,10 +208,10 @@ class RelevantContentBlockTest < ActiveSupport::TestCase |
208 | 208 | person = fast_create(Person) |
209 | 209 | person.vote_for(article) |
210 | 210 | end |
211 | - | |
211 | + | |
212 | 212 | articles = Article.more_negative_votes(Environment.default, 5) |
213 | 213 | assert_equal '23 votes for 29 votes against', articles.first.name |
214 | 214 | assert_equal '2 votes against', articles.last.name |
215 | 215 | end |
216 | - | |
216 | + | |
217 | 217 | end | ... | ... |
plugins/relevant_content/views/box_organizer/relevant_content_plugin/_relevant_content_block.rhtml
1 | 1 | <div id='edit-relevant-content-block'> |
2 | - <%= labelled_form_field _('Limit of items per category'), text_field(:block, :limit, :size => 3) %> | |
2 | + <%= labelled_form_field _('Limit of items per category'), text_field(:block, :limit, :size => 3) %> | |
3 | 3 | <%= labelled_check_box _('Display most accessed content'), "block[show_most_read]", 1 ,@block.show_most_read != 0 %><BR> |
4 | 4 | <%= labelled_check_box _('Display most commented content'), "block[show_most_commented]", 1 ,@block.show_most_commented != 0 %><BR> |
5 | - <%= labelled_check_box _('Display most liked content'), "block[show_most_liked]", 1 ,@block.show_most_liked != 0 %><BR> | |
6 | - <%= labelled_check_box _('Display most voted content'), "block[show_most_voted]", 1 ,@block.show_most_voted != 0 %><BR> | |
7 | - <%= labelled_check_box _('Display most disliked content'), "block[show_most_disliked]", 1 , @block.show_most_disliked != 0 %><BR> | |
5 | + <%= labelled_check_box _('Display most liked content'), "block[show_most_liked]", 1 ,@block.show_most_liked != 0 %><BR> | |
6 | + <%= labelled_check_box _('Display most voted content'), "block[show_most_voted]", 1 ,@block.show_most_voted != 0 %><BR> | |
7 | + <%= labelled_check_box _('Display most disliked content'), "block[show_most_disliked]", 1 , @block.show_most_disliked != 0 %><BR> | |
8 | 8 | </div> |
9 | 9 | |
10 | 10 | |
11 | - | |
11 | + | |
12 | 12 | ... | ... |