Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Autolink URLs in story description #220

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/javascripts/templates/story_hover.jst.ejs
Expand Up @@ -16,7 +16,7 @@
</div>
<% if (story.get('description')) { %>
<h4 class="title"><%= story.humanAttributeName('description') %></h4>
<div class="description"><%= window.md.makeHtml(story.escape('description')) %></div>
<div class="description"><%= window.md.makeHtml(story.get('description')) %></div>
<% } %>
<% if (story.hasNotes()) { %>
<h5 class="title"><%= I18n.t('notes') %></h5>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/story_view.js
Expand Up @@ -346,7 +346,7 @@ Fulcrum.StoryView = Fulcrum.FormView.extend({
var description = this.make('div');
$(description).addClass('description');
$(description).html(
window.md.makeHtml(this.model.escape('description'))
window.md.makeHtml(this.model.get('description') || "")
);
$(div).append(description);
$(description).after(
Expand Down
48 changes: 48 additions & 0 deletions spec/features/stories_spec.rb
Expand Up @@ -118,6 +118,54 @@
end
end

describe 'formatting' do
let(:title) { 'My story' }
let!(:story) { FactoryGirl.create :story, title: title, description: description, project: project, requested_by: user }

before do
Capybara.ignore_hidden_elements = true
visit project_path project
end

describe 'description', js: true do
let(:expand_story) { find('.story-title', text: title).click }
let(:hover_story) { find('.popover-activate').hover }

describe '*italics*' do
let(:description) { 'Text with *italics*.' }

specify 'edit form' do
expand_story
page.should have_css :em, text: 'italics'
end
end

describe 'autolink URLs' do
let(:url) { 'http://www.google.com' }
let(:description) { "Text with a URL: #{url}" }

specify 'edit form' do
expand_story
page.should have_css "a[href='#{url}']", text: url
end

specify 'hover' do
hover_story
page.should have_css "a[href='#{url}']", text: url
end
end

describe 'handle blank correctly' do
let(:description) { nil }

specify 'edit form' do
expand_story
page.should have_css '.description'
end
end
end
end

def story_selector(story)
"#story-#{story.id}"
end
Expand Down