From eddf305e130840b30453d3ba19c6fe1f30606760 Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Mon, 23 Dec 2013 23:23:36 -0500 Subject: [PATCH 1/4] Autolink URLs. --- app/assets/javascripts/views/story_view.js | 2 +- spec/features/stories_spec.rb | 32 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/views/story_view.js b/app/assets/javascripts/views/story_view.js index d12412bfa..bfdd42312 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..1c343b36d 100644 --- a/spec/features/stories_spec.rb +++ b/spec/features/stories_spec.rb @@ -118,6 +118,38 @@ end end + describe 'formatting' do + before do + Capybara.ignore_hidden_elements = true + visit project_path project + end + + describe 'description', js: true do + let(:title) { 'My story' } + let(:expand_story) { find('.story-title', text: 'My story').click } + + before do + click_on 'Add story' + fill_in 'title', with: title + end + + it 'shows *italics*' do + fill_in 'description', with: 'Text with *italics*.' + within('.story-controls') { click_on 'Save' } + expand_story + page.should have_css :em, text: 'italics' + end + + it 'autolinks URLs' do + url = 'http://www.google.com' + fill_in 'description', with: "Text with a URL: #{url}" + within('.story-controls') { click_on 'Save' } + expand_story + page.should have_css "a[href='#{url}']", text: url + end + end + end + def story_selector(story) "#story-#{story.id}" end From b5f47b631b7772c50e46bee455e494817d46b692 Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Sun, 2 Mar 2014 15:19:54 -0500 Subject: [PATCH 2/4] Make specs more reliable. --- spec/features/stories_spec.rb | 40 ++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/spec/features/stories_spec.rb b/spec/features/stories_spec.rb index 1c343b36d..c78e477a8 100644 --- a/spec/features/stories_spec.rb +++ b/spec/features/stories_spec.rb @@ -119,33 +119,39 @@ 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(:title) { 'My story' } - let(:expand_story) { find('.story-title', text: 'My story').click } + let(:expand_story) { find('.story-title', text: title).click } - before do - click_on 'Add story' - fill_in 'title', with: title - end + describe '*italics*' do + let(:description) { 'Text with *italics*.' } - it 'shows *italics*' do - fill_in 'description', with: 'Text with *italics*.' - within('.story-controls') { click_on 'Save' } - expand_story - page.should have_css :em, text: 'italics' + specify 'edit form' do + expand_story + page.should have_css :em, text: 'italics' + end end - it 'autolinks URLs' do - url = 'http://www.google.com' - fill_in 'description', with: "Text with a URL: #{url}" - within('.story-controls') { click_on 'Save' } - expand_story - page.should have_css "a[href='#{url}']", text: url + 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 + + xspecify 'hover' do + find('.popover-activate').hover + page.should have_css "a[href='#{url}']", text: url + end end end end From d65e659e4921435b557677a425cde9faec90d576 Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Sun, 2 Mar 2014 22:25:41 -0500 Subject: [PATCH 3/4] Autolink in hover balloon as well. --- app/assets/javascripts/templates/story_hover.jst.ejs | 2 +- spec/features/stories_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/spec/features/stories_spec.rb b/spec/features/stories_spec.rb index c78e477a8..3a30c7416 100644 --- a/spec/features/stories_spec.rb +++ b/spec/features/stories_spec.rb @@ -148,7 +148,7 @@ page.should have_css "a[href='#{url}']", text: url end - xspecify 'hover' do + specify 'hover' do find('.popover-activate').hover page.should have_css "a[href='#{url}']", text: url end From 60b302447d7f04525eb7450786c6da2bd33c422a Mon Sep 17 00:00:00 2001 From: Marnen Laibow-Koser Date: Sun, 2 Mar 2014 23:04:57 -0500 Subject: [PATCH 4/4] Handle blank description correctly. --- app/assets/javascripts/views/story_view.js | 2 +- spec/features/stories_spec.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/views/story_view.js b/app/assets/javascripts/views/story_view.js index bfdd42312..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.get('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 3a30c7416..d95a6e6b1 100644 --- a/spec/features/stories_spec.rb +++ b/spec/features/stories_spec.rb @@ -129,6 +129,7 @@ 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*.' } @@ -149,10 +150,19 @@ end specify 'hover' do - find('.popover-activate').hover + 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