mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-01 06:48:49 +01:00
Spec and fix bug #776 by using auto_link instead of my dumb regex
This commit is contained in:
parent
01c7fd1296
commit
05f21ebba2
4 changed files with 71 additions and 2 deletions
|
|
@ -2,7 +2,7 @@
|
|||
<div id="<%= dom_id(note, 'container') %>">
|
||||
<h2><%= link_to("Note #{note.id}", note_path(note), :title => "Show note #{note.id}" ) %></h2>
|
||||
<div id="<%= dom_id(note) %>">
|
||||
<%= sanitize(textilize(note.body.gsub(/((https?:\/\/[^ \n\t]*))/, '"\1":\2'))) %>
|
||||
<%= sanitize(markdown(auto_link(note.body))) %>
|
||||
|
||||
<div class="note_footer">
|
||||
<%= link_to_remote(
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
element.next('.todo_notes').toggle
|
||||
end -%>
|
||||
<div class="todo_notes" id="<%= dom_id(item, 'notes') %>" style="display:none">
|
||||
<%= markdown( item.notes.gsub(/((https?:\/\/[^ \n\t]*))/, '"\1":\2') ) %>
|
||||
<%= sanitize(markdown( auto_link(item.notes)) ) %>
|
||||
</div>
|
||||
36
spec/views/notes/_notes.rhtml_spec.rb
Normal file
36
spec/views/notes/_notes.rhtml_spec.rb
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe "/notes/_notes.rhtml" do
|
||||
before :each do
|
||||
@project = mock_model(Project, :name => "a project")
|
||||
@note = mock_model(Note, :body => "this is a note", :project => @project,
|
||||
:created_at => Time.now, :updated_at? => false)
|
||||
@controller.template.stub!(:apply_behavior)
|
||||
@controller.template.stub!(:format_date)
|
||||
@controller.template.stub!(:render)
|
||||
@controller.template.stub!(:form_remote_tag)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
render :partial => "/notes/notes", :locals => {:notes => @note}
|
||||
response.should have_tag("div.note_footer")
|
||||
end
|
||||
|
||||
it "should auto-link URLs" do
|
||||
@note.stub!(:body).and_return("http://www.google.com/")
|
||||
render :partial => "/notes/notes", :locals => {:notes => @note}
|
||||
response.should have_tag("a[href=\"http://www.google.com/\"]")
|
||||
end
|
||||
|
||||
it "should auto-link embedded URLs" do
|
||||
@note.stub!(:body).and_return("this is cool: http://www.google.com/")
|
||||
render :partial => "/notes/notes", :locals => {:notes => @note}
|
||||
response.should have_tag("a[href=\"http://www.google.com/\"]")
|
||||
end
|
||||
|
||||
it "should parse Textile links correctly" do
|
||||
@note.stub!(:body).and_return("\"link\":http://www.google.com/")
|
||||
render :partial => "/notes/notes", :locals => {:notes => @note}
|
||||
response.should have_tag("a[href=\"http://www.google.com/\"]")
|
||||
end
|
||||
end
|
||||
33
spec/views/todos/_toggle_notes.rhtml_spec.rb
Normal file
33
spec/views/todos/_toggle_notes.rhtml_spec.rb
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
require File.dirname(__FILE__) + '/../../spec_helper'
|
||||
|
||||
describe "/todos/_toggle_notes.rhtml" do
|
||||
# include ControllerHelper
|
||||
|
||||
before :each do
|
||||
@item = mock_model(Todo, :notes => "this is a note")
|
||||
@controller.template.stub!(:apply_behavior)
|
||||
end
|
||||
|
||||
it "should render" do
|
||||
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
|
||||
response.should have_tag("div.todo_notes")
|
||||
end
|
||||
|
||||
it "should auto-link URLs" do
|
||||
@item.stub!(:notes).and_return("http://www.google.com/")
|
||||
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
|
||||
response.should have_tag("a[href=\"http://www.google.com/\"]")
|
||||
end
|
||||
|
||||
it "should auto-link embedded URLs" do
|
||||
@item.stub!(:notes).and_return("this is cool: http://www.google.com/")
|
||||
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
|
||||
response.should have_tag("a[href=\"http://www.google.com/\"]")
|
||||
end
|
||||
|
||||
it "should parse Textile URLs correctly" do
|
||||
@item.stub!(:notes).and_return("\"link\":http://www.google.com/")
|
||||
render :partial => "/todos/toggle_notes", :locals => {:item => @item}
|
||||
response.should have_tag("a[href=\"http://www.google.com/\"]")
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue