Fixed failing tests

- Some fixtures added by Erik Ordway broke tests
- message:// links had an edge case I broke with 68701ada
- One test had a hard-coded id that changed

Closes #1019
This commit is contained in:
Eric Allen 2010-04-09 09:34:57 -04:00
parent 68701adaca
commit a022f449c1
7 changed files with 9 additions and 45 deletions

View file

@ -196,15 +196,15 @@ module ApplicationHelper
# do not change string; URL is alreay linked
href
else
content_tag(:a, h(href), :href => h(href))
content = content_tag(:a, h(href), :href => h(href))
end
end
end
def format_note(note)
note = markdown(note)
note = auto_link_message(note)
note = auto_link(note)
note = markdown(note)
note = auto_link(note, :link => :urls)
# add onenote and message protocols
Sanitize::Config::RELAXED[:protocols]['a']['href'] << 'onenote'

View file

@ -288,7 +288,7 @@ class Todo < ActiveRecord::Base
end
def notes=(value)
super(value.gsub(/</, '&lt;').gsub(/>/, '&gt;'))
super(value.try(:gsub, /</, '&lt;').try(:gsub, />/, '&gt;'))
end
def raw_notes=(value)

View file

@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe MessageGateway do
before :each do
todo = mock_model(Todo, :description= => nil, :notes= => nil, :context_id= => nil, :save! => nil)
todo = mock_model(Todo, :description= => nil, :raw_notes= => nil, :context_id= => nil, :save! => nil)
@user = mock_model(User,
:prefs => mock_model(Preference, :sms_context => mock_model(Context)),

View file

@ -131,21 +131,3 @@ anothercontext:
user_id: 4
created_at: <%= today %>
updated_at: <%= today %>
inbox:
id: 15
name: Inbox
position: 1
hide: false
user_id: 5
created_at: <%= today %>
updated_at: <%= today %>
anothercontext:
id: 16
name: anothercontext
position: 2
hide: false
user_id: 5
created_at: <%= today %>
updated_at: <%= today %>

View file

@ -54,21 +54,3 @@ sms_user_prefs:
show_project_on_todo_done: true
sms_email: 5555555555@tmomail.net
sms_context_id: 13
other_user_prefs:
id: 4
user_id: 5
staleness_starts: 7
date_format: "%d/%m/%Y"
title_date_format: "%A, %d %B %Y"
show_number_completed: 5
show_completed_projects_in_sidebar: true
show_hidden_contexts_in_sidebar: true
show_hidden_projects_in_sidebar: true
admin_email: butshesagirl@rousette.org.uk
week_starts: 1
due_style: 0
refresh: 0
time_zone: "Los_Angeles"
verbose_action_descriptors: false
show_project_on_todo_done: true

View file

@ -542,10 +542,9 @@ class TodosControllerTest < ActionController::TestCase
def test_format_note_link_message
login_as(:admin_user)
todo = users(:admin_user).todos.first
todo.notes = "A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link"
todo.raw_notes = "A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link"
todo.save!
get :index
# puts css_select("div#notes_todo_#{todo.id}")
assert_select("div#notes_todo_#{todo.id}", 'A Mail.app message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt; link')
assert_select("div#notes_todo_#{todo.id} a", 'message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt;')
assert_select("div#notes_todo_#{todo.id} a[href=message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt;]", 'message://&lt;ABCDEF-GHADB-123455-FOO-BAR@example.com&gt;')

View file

@ -52,8 +52,9 @@ class UsersControllerTest < ActionController::TestCase
def test_destroy_user
login_as :admin_user
@no_users_before = User.find(:all).size
xhr :post, :destroy, :id => users(:ldap_user).id.to_param
assert_rjs :page, "user-3", :remove
user_id = users(:ldap_user).id
xhr :post, :destroy, :id => user_id.to_param
assert_rjs :page, "user-#{user_id}", :remove
assert_equal @no_users_before-1, User.find(:all).size
end