From f6e5cc3c37f83044ca06d82aacf8ccb2796df724 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9my=20Coutable?= <remy@rymai.me>
Date: Tue, 20 Sep 2016 10:45:00 +0200
Subject: [PATCH] Add a view spec for projects/notes/_form
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Rémy Coutable <remy@rymai.me>
---
 spec/features/projects/commits/note_spec.rb   | 16 ---------
 .../projects/notes/_form.html.haml_spec.rb    | 36 +++++++++++++++++++
 2 files changed, 36 insertions(+), 16 deletions(-)
 delete mode 100644 spec/features/projects/commits/note_spec.rb
 create mode 100644 spec/views/projects/notes/_form.html.haml_spec.rb

diff --git a/spec/features/projects/commits/note_spec.rb b/spec/features/projects/commits/note_spec.rb
deleted file mode 100644
index bc42b63c371..00000000000
--- a/spec/features/projects/commits/note_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'spec_helper'
-
-describe 'Projects > Commits > Note' do
-  let(:project) { create(:project) }
-  let(:commit)  { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
-
-  before do
-    login_as :user
-    project.team << [@user, :master]
-    visit namespace_project_commit_path(project.namespace, project, commit.id)
-  end
-
-  it 'says that only markdown is supported, not slash commands' do
-    expect(page).to have_content('Styling with Markdown is supported')
-  end
-end
diff --git a/spec/views/projects/notes/_form.html.haml_spec.rb b/spec/views/projects/notes/_form.html.haml_spec.rb
new file mode 100644
index 00000000000..932d6756ad2
--- /dev/null
+++ b/spec/views/projects/notes/_form.html.haml_spec.rb
@@ -0,0 +1,36 @@
+require 'spec_helper'
+
+describe 'projects/notes/_form' do
+  include Devise::TestHelpers
+
+  let(:user) { create(:user) }
+  let(:project) { create(:empty_project) }
+
+  before do
+    project.team << [user, :master]
+    assign(:project, project)
+    assign(:note, note)
+
+    allow(view).to receive(:current_user).and_return(user)
+
+    render
+  end
+
+  %w[issue merge_request].each do |noteable|
+    context "with a note on #{noteable}" do
+      let(:note) { build(:"note_on_#{noteable}", project: project) }
+
+      it 'says that only markdown is supported, not slash commands' do
+        expect(rendered).to have_content('Styling with Markdown and slash commands are supported')
+      end
+    end
+  end
+
+  context 'with a note on a commit' do
+    let(:note) { build(:note_on_commit, project: project) }
+
+    it 'says that only markdown is supported, not slash commands' do
+      expect(rendered).to have_content('Styling with Markdown is supported')
+    end
+  end
+end
-- 
GitLab