Commit 0b7fa47766533c7df4be20357c2de32337d9921d
1 parent
1771bd86
Exists in
master
and in
29 other branches
Fix FeedReaderBlock unit test
Showing
3 changed files
with
12 additions
and
5 deletions
Show diff stats
app/models/feed_reader_block.rb
1 | class FeedReaderBlock < Block | 1 | class FeedReaderBlock < Block |
2 | 2 | ||
3 | + attr_accessible :address, :update_errors | ||
4 | + | ||
3 | def initialize(attributes = nil) | 5 | def initialize(attributes = nil) |
4 | data = attributes || {} | 6 | data = attributes || {} |
5 | - super({ :enabled => !data[:address].blank? }.merge(data)) | 7 | + super(data) |
8 | + self.enabled= !data[:address].blank? | ||
6 | end | 9 | end |
7 | 10 | ||
8 | include DatesHelper | 11 | include DatesHelper |
app/models/profile_list_block.rb
@@ -44,7 +44,7 @@ class ProfileListBlock < Block | @@ -44,7 +44,7 @@ class ProfileListBlock < Block | ||
44 | profiles = self.profile_list | 44 | profiles = self.profile_list |
45 | title = self.view_title | 45 | title = self.view_title |
46 | nl = "\n" | 46 | nl = "\n" |
47 | - lambda do |context| | 47 | + proc do |context| |
48 | count=0 | 48 | count=0 |
49 | list = profiles.map {|item| | 49 | list = profiles.map {|item| |
50 | count+=1 | 50 | count+=1 |
test/unit/feed_reader_block_test.rb
@@ -113,8 +113,10 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -113,8 +113,10 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
113 | should 'expire after a period' do | 113 | should 'expire after a period' do |
114 | # save current time | 114 | # save current time |
115 | now = Time.now | 115 | now = Time.now |
116 | - expired = FeedReaderBlock.create! | ||
117 | - not_expired = FeedReaderBlock.create! | 116 | + expired = FeedReaderBlock.new |
117 | + expired.save | ||
118 | + not_expired = FeedReaderBlock.new | ||
119 | + not_expired.save | ||
118 | 120 | ||
119 | # Noosfero is configured to update feeds every 4 hours | 121 | # Noosfero is configured to update feeds every 4 hours |
120 | FeedUpdater.stubs(:update_interval).returns(4.hours) | 122 | FeedUpdater.stubs(:update_interval).returns(4.hours) |
@@ -168,7 +170,9 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -168,7 +170,9 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
168 | end | 170 | end |
169 | 171 | ||
170 | should 'be disabled when address is empty' do | 172 | should 'be disabled when address is empty' do |
171 | - reader = build(:feed_reader_block, :enabled => true, :address => 'http://www.example.com/feed') | 173 | + reader = build(:feed_reader_block, :address => 'http://www.example.com/feed').tap do |f| |
174 | + f.enabled = true | ||
175 | + end | ||
172 | reader.address = nil | 176 | reader.address = nil |
173 | assert_equal false, reader.enabled | 177 | assert_equal false, reader.enabled |
174 | end | 178 | end |