mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-25 11:38:49 +01:00
The recent changeset to the API introduced some test failures. I fixed those and also eliminated some warnings that were appearing while running the tests.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@600 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
01824384c3
commit
17a880d2fa
7 changed files with 20 additions and 17 deletions
|
|
@ -47,7 +47,7 @@ module ApplicationHelper
|
|||
"<a title='#{format_date(due)}'><span class=\"amber\">Due Tomorrow</span></a> "
|
||||
# due 2-7 days away
|
||||
when 2..7
|
||||
if prefs.due_style == Preference::DUE_ON_DUE_STYLE
|
||||
if prefs.due_style == Preference.due_styles[:due_on]
|
||||
"<a title='#{format_date(due)}'><span class=\"orange\">Due on #{due.strftime("%A")}</span></a> "
|
||||
else
|
||||
"<a title='#{format_date(due)}'><span class=\"orange\">Due in #{pluralize(days, 'day')}</span></a> "
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@ module FeedlistHelper
|
|||
|
||||
def rss_formatted_link(options = {})
|
||||
image_tag = image_tag("feed-icon.png", :size => "16X16", :border => 0, :class => "rss-icon")
|
||||
linkoptions = merge_hashes( { :format => 'rss'}, user_token_hash, options)
|
||||
linkoptions = merge_hashes( {:format => 'rss'}, user_token_hash, options)
|
||||
link_to(image_tag, linkoptions, :title => "RSS feed")
|
||||
end
|
||||
|
||||
def text_formatted_link(options = {})
|
||||
linkoptions = merge_hashes( { :format => 'txt'}, user_token_hash, options)
|
||||
linkoptions = merge_hashes( {:format => 'txt'}, user_token_hash, options)
|
||||
link_to('<span class="feed">TXT</span>', linkoptions, :title => "Plain text feed" )
|
||||
end
|
||||
|
||||
def ical_formatted_link(options = {})
|
||||
linkoptions = merge_hashes ( { :format => 'ics'}, user_token_hash, options)
|
||||
linkoptions = merge_hashes( {:format => 'ics'}, user_token_hash, options)
|
||||
link_to('<span class="feed">iCal</span>', linkoptions, :title => "iCal feed" )
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ module TodosHelper
|
|||
"<a title='" + format_date(due) + "'><span class=\"amber\">Show Tomorrow</span></a> "
|
||||
# due 2-7 days away
|
||||
when 2..7
|
||||
if prefs.due_style == Preference::DUE_ON_DUE_STYLE
|
||||
if prefs.due_style == Preference.due_styles[:due_on]
|
||||
"<a title='" + format_date(due) + "'><span class=\"orange\">Show on " + due.strftime("%A") + "</span></a> "
|
||||
else
|
||||
"<a title='" + format_date(due) + "'><span class=\"orange\">Show in " + days.to_s + " days</span></a> "
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@ class Preference < ActiveRecord::Base
|
|||
composed_of :tz,
|
||||
:class_name => 'TimeZone',
|
||||
:mapping => %w(time_zone name)
|
||||
|
||||
DUE_ON_DUE_STYLE = 1
|
||||
DUE_IN_N_DAYS_DUE_STYLE = 0
|
||||
|
||||
|
||||
def self.due_styles
|
||||
{ :due_in_n_days => 0, :due_on => 1}
|
||||
end
|
||||
|
||||
def self.day_number_to_name_map
|
||||
{ 0 => "Sunday",
|
||||
1 => "Monday",
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
<%= table_row('time_zone', false) { time_zone_select('prefs','time_zone') } %>
|
||||
|
||||
<%= row_with_select_field("week_starts", Preference.day_number_to_name_map.invert.sort{|a,b| a[1]<=>b[1]})%>
|
||||
<%= row_with_select_field("due_style", [['Due in ___ days',Preference::DUE_IN_N_DAYS_DUE_STYLE],['Due on _______',Preference::DUE_ON_DUE_STYLE]]) %>
|
||||
<%= row_with_select_field("due_style", [['Due in ___ days',Preference.due_styles[:due_in_n_days]],['Due on _______',Preference.due_styles[:due_on]]]) %>
|
||||
<%= row_with_select_field("show_completed_projects_in_sidebar") %>
|
||||
<%= row_with_select_field("show_hidden_projects_in_sidebar") %>
|
||||
<%= row_with_select_field("show_hidden_contexts_in_sidebar") %>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
<li>Go to project page on todo complete: <span class="highlight"><%= prefs.show_project_on_todo_done %></span></li>
|
||||
<li>Staleness starts after <span class="highlight"><%= prefs.staleness_starts %></span> days</li>
|
||||
<li>Due style: <span class="highlight">
|
||||
<% if prefs.due_style == Preference::DUE_IN_N_DAYS_DUE_STYLE %>
|
||||
<% if prefs.due_style == Preference.due_styles[:due_in_n_days] %>
|
||||
Due in ___ days
|
||||
<% else %>
|
||||
Due on ________
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ class BackendControllerTest < Test::Rails::TestCase
|
|||
end
|
||||
|
||||
def test_new_todo_fails_with_incorrect_token
|
||||
assert_raises_invalid_token { @controller.new_todo('admin', 'notthecorrecttoken', contexts('agenda').id, 'test') }
|
||||
assert_raises_invalid_token { @controller.new_todo('admin', 'notthecorrecttoken', contexts('agenda').id, 'test', 'test') }
|
||||
end
|
||||
|
||||
def test_new_todo_fails_with_context_that_does_not_belong_to_user
|
||||
assert_raise(CannotAccessContext, "Cannot access a context that does not belong to this user.") { @controller.new_todo(users('other_user').login, users('other_user').token, contexts('agenda').id, 'test') }
|
||||
assert_raise(CannotAccessContext, "Cannot access a context that does not belong to this user.") { @controller.new_todo(users('other_user').login, users('other_user').token, contexts('agenda').id, 'test', 'test') }
|
||||
end
|
||||
|
||||
def test_new_rich_todo_fails_with_incorrect_token
|
||||
assert_raises_invalid_token { @controller.new_rich_todo('admin', 'notthecorrecttoken', contexts('agenda').id, 'test') }
|
||||
assert_raises_invalid_token { @controller.new_rich_todo('admin', 'notthecorrecttoken', contexts('agenda').id, 'test', 'test') }
|
||||
end
|
||||
|
||||
#"Call mfox @call > Build a working time machine" should create the "Call mfox" todo in the 'call' context and the 'Build a working time machine' project.
|
||||
|
|
@ -39,27 +39,29 @@ class BackendControllerTest < Test::Rails::TestCase
|
|||
def test_new_rich_todo_creates_todo_with_new_project
|
||||
max_todo_id = Todo.maximum('id')
|
||||
max_project_id = Project.maximum('id')
|
||||
@controller.new_rich_todo(users(:admin_user).login, users(:admin_user).token, contexts(:agenda).id, 'Call mfox @call > new:Run for president')
|
||||
@controller.new_rich_todo(users(:admin_user).login, users(:admin_user).token, contexts(:agenda).id, 'Call mfox @call > new:Run for president', 'test')
|
||||
todo = Todo.find(:first, :conditions => ["id > ?", max_todo_id])
|
||||
new_project = Project.find(:first, :conditions => ["id > ?", max_project_id])
|
||||
assert_equal(users(:admin_user).id, todo.user_id)
|
||||
assert_equal(contexts(:call).id, todo.context_id)
|
||||
assert_equal(new_project.id, todo.project_id)
|
||||
assert_equal("Call mfox", todo.description)
|
||||
assert_equal("test", todo.notes)
|
||||
end
|
||||
|
||||
def assert_new_rich_todo_creates_mfox_todo(description_input)
|
||||
max_id = Todo.maximum('id')
|
||||
@controller.new_rich_todo(users(:admin_user).login, users(:admin_user).token, contexts(:agenda).id, 'Call mfox @cal > Build')
|
||||
@controller.new_rich_todo(users(:admin_user).login, users(:admin_user).token, contexts(:agenda).id, 'Call mfox @cal > Build', 'test')
|
||||
todo = Todo.find(:first, :conditions => ["id > ?", max_id])
|
||||
assert_equal(users(:admin_user).id, todo.user_id)
|
||||
assert_equal(contexts(:call).id, todo.context_id)
|
||||
assert_equal(projects(:timemachine).id, todo.project_id)
|
||||
assert_equal('test', todo.notes)
|
||||
assert_equal("Call mfox", todo.description)
|
||||
end
|
||||
|
||||
def test_new_rich_todo_fails_with_context_that_does_not_belong_to_user
|
||||
assert_raise(CannotAccessContext, "Cannot access a context that does not belong to this user.") { @controller.new_rich_todo(users('other_user').login, users('other_user').token, contexts('agenda').id, 'test') }
|
||||
assert_raise(CannotAccessContext, "Cannot access a context that does not belong to this user.") { @controller.new_rich_todo(users('other_user').login, users('other_user').token, contexts('agenda').id, 'test', 'test') }
|
||||
end
|
||||
|
||||
def test_list_projects_fails_with_incorrect_token
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue