diff --git a/app/assets/javascripts/templates/story_hover.jst.ejs b/app/assets/javascripts/templates/story_hover.jst.ejs
index c65faad2c..210c57386 100644
--- a/app/assets/javascripts/templates/story_hover.jst.ejs
+++ b/app/assets/javascripts/templates/story_hover.jst.ejs
@@ -16,7 +16,7 @@
<% if (story.get('description')) { %>
<%= story.humanAttributeName('description') %>
- <%= window.md.makeHtml(story.escape('description')) %>
+ <%= window.md.makeHtml(story.get('description')) %>
<% } %>
<% if (story.hasNotes()) { %>
<%= I18n.t('notes') %>
diff --git a/app/assets/javascripts/views/story_view.js b/app/assets/javascripts/views/story_view.js
index d12412bfa..9f831a559 100644
--- a/app/assets/javascripts/views/story_view.js
+++ b/app/assets/javascripts/views/story_view.js
@@ -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(
diff --git a/spec/features/stories_spec.rb b/spec/features/stories_spec.rb
index 30f2778b4..d95a6e6b1 100644
--- a/spec/features/stories_spec.rb
+++ b/spec/features/stories_spec.rb
@@ -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