mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 22:41:48 +01:00
Broken project and context feeds were caused by NULL created_at/updated_at fields in the projects and contexts tables. This changeset makes the models user Time.now if those fields are nil. It would be best to set these fields to non-null values, but I'm not quite sure how to write that migration yet. Fixes #438.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@440 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
3dbc39113e
commit
6aae34156e
9 changed files with 45 additions and 11 deletions
|
|
@ -41,5 +41,14 @@ class Context < ActiveRecord::Base
|
|||
s += "</p>"
|
||||
s
|
||||
end
|
||||
|
||||
def created_at
|
||||
read_attribute(:created_at) || Time.now.utc
|
||||
end
|
||||
|
||||
def updated_at
|
||||
read_attribute(:updated_at) || Time.now.utc
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -60,6 +60,14 @@ class Project < ActiveRecord::Base
|
|||
name
|
||||
end
|
||||
|
||||
def created_at
|
||||
read_attribute(:created_at) || Time.now
|
||||
end
|
||||
|
||||
def updated_at
|
||||
read_attribute(:updated_at) || Time.now
|
||||
end
|
||||
|
||||
def summary(undone_todo_count)
|
||||
project_description = ''
|
||||
project_description += sanitize(markdown( description )) if description_present?
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Rails::Initializer.run do |config|
|
|||
# config.active_record.observers = :cacher, :garbage_collector
|
||||
|
||||
# Make Active Record use UTC-base instead of local time
|
||||
# config.active_record.default_timezone = :utc
|
||||
config.active_record.default_timezone = :utc
|
||||
|
||||
# Use Active Record's schema dumper instead of SQL when creating the test database
|
||||
# (enables use of different database adapters for development and test environments)
|
||||
|
|
|
|||
4
tracks/test/fixtures/contexts.yml
vendored
4
tracks/test/fixtures/contexts.yml
vendored
|
|
@ -57,8 +57,8 @@ library:
|
|||
position: 6
|
||||
hide: false
|
||||
user_id: 1
|
||||
created_at: <%= today %>
|
||||
updated_at: <%= today %>
|
||||
created_at: nil
|
||||
updated_at: nil
|
||||
|
||||
freetime:
|
||||
id: 7
|
||||
|
|
|
|||
4
tracks/test/fixtures/projects.yml
vendored
4
tracks/test/fixtures/projects.yml
vendored
|
|
@ -24,8 +24,8 @@ moremoney:
|
|||
position: 2
|
||||
state: 'active'
|
||||
user_id: 1
|
||||
created_at: <%= today %>
|
||||
updated_at: <%= today %>
|
||||
created_at: nil
|
||||
updated_at: nil
|
||||
|
||||
gardenclean:
|
||||
id: 3
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class ContextsControllerTest < TodoContainerControllerTestBase
|
|||
%w(guid link).each do |node|
|
||||
assert_xml_select node, /http:\/\/test.host\/contexts\/.+/
|
||||
end
|
||||
assert_xml_select 'pubDate', contexts(:agenda).created_at.to_s(:rfc822)
|
||||
assert_xml_select 'pubDate', /(#{contexts(:agenda).created_at.to_s(:rfc822)}|#{contexts(:library).created_at.to_s(:rfc822)})/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -94,7 +94,7 @@ class ContextsControllerTest < TodoContainerControllerTestBase
|
|||
assert_xml_select 'entry', 3 do
|
||||
assert_xml_select 'title', /.+/
|
||||
assert_xml_select 'content[type="html"]', /<p>\d+ actions. Context is (active|hidden). <\/p>/
|
||||
assert_xml_select 'published', contexts(:agenda).created_at.to_s(:rfc822)
|
||||
assert_xml_select 'published', /(#{contexts(:agenda).created_at.to_s(:rfc822)}|#{contexts(:library).created_at.to_s(:rfc822)})/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -97,11 +97,11 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
%w(guid link).each do |node|
|
||||
assert_xml_select node, /http:\/\/test.host\/projects\/.+/
|
||||
end
|
||||
assert_xml_select 'pubDate', projects(:timemachine).created_at.to_s(:rfc822)
|
||||
assert_xml_select 'pubDate', /(#{projects(:timemachine).updated_at.to_s(:rfc822)}|#{projects(:moremoney).updated_at.to_s(:rfc822)}})/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_rss_feed_not_accessible_to_anonymous_user_without_token
|
||||
@request.session['user_id'] = nil
|
||||
get :index, { :format => "rss" }
|
||||
|
|
@ -132,11 +132,11 @@ class ProjectsControllerTest < TodoContainerControllerTestBase
|
|||
assert_xml_select 'entry', 3 do
|
||||
assert_xml_select 'title', /.+/
|
||||
assert_xml_select 'content[type="html"]', /<p>\d+ actions. Project is (active|hidden|completed). <\/p>/
|
||||
assert_xml_select 'published', projects(:timemachine).created_at.to_s(:rfc822)
|
||||
assert_xml_select 'published', /(#{projects(:timemachine).updated_at.to_s(:rfc822)}|#{projects(:moremoney).updated_at.to_s(:rfc822)}})/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_atom_feed_not_accessible_to_anonymous_user_without_token
|
||||
@request.session['user_id'] = nil
|
||||
get :index, { :format => "atom" }
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class ContextTest < Test::Unit::TestCase
|
|||
def setup
|
||||
@agenda = contexts(:agenda)
|
||||
@email = contexts(:email)
|
||||
@library = contexts(:library)
|
||||
end
|
||||
|
||||
def test_validate_presence_of_name
|
||||
|
|
@ -112,4 +113,12 @@ class ContextTest < Test::Unit::TestCase
|
|||
assert_equal @agenda.name, @agenda.title
|
||||
end
|
||||
|
||||
def test_created_at_returns_now_when_field_null
|
||||
assert_equal Time.now.utc.to_s, @library.created_at.to_s
|
||||
end
|
||||
|
||||
def test_updated_at_returns_now_when_field_null
|
||||
assert_equal Time.now.utc.to_s, @library.updated_at.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -147,4 +147,12 @@ class ProjectTest < Test::Unit::TestCase
|
|||
assert_equal @timemachine.name, @timemachine.title
|
||||
end
|
||||
|
||||
def test_created_at_returns_now_when_field_null
|
||||
assert_equal Time.now.to_s, @moremoney.created_at.to_s
|
||||
end
|
||||
|
||||
def test_updated_at_returns_now_when_field_null
|
||||
assert_equal Time.now.to_s, @moremoney.updated_at.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue