summaryrefslogtreecommitdiff
path: root/spec/features/issues/user_creates_issue_spec.rb
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2018-08-30 17:18:01 +0200
committerRémy Coutable <remy@rymai.me>2018-08-30 17:18:01 +0200
commitd004c768417ef95a4aecb58c6c241ceed1a73d8f (patch)
tree7dafc633b9592911af9657d22e0298e912a56c77 /spec/features/issues/user_creates_issue_spec.rb
parent418d35d97491af3921e8f5cca2734b0063c143a9 (diff)
downloadgitlab-ce-d004c768417ef95a4aecb58c6c241ceed1a73d8f.tar.gz
Reorganize issues and merge request feature specs in the same folder
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/features/issues/user_creates_issue_spec.rb')
-rw-r--r--spec/features/issues/user_creates_issue_spec.rb90
1 files changed, 90 insertions, 0 deletions
diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb
new file mode 100644
index 00000000000..5e8662100c5
--- /dev/null
+++ b/spec/features/issues/user_creates_issue_spec.rb
@@ -0,0 +1,90 @@
+require "spec_helper"
+
+describe "User creates issue" do
+ let(:project) { create(:project_empty_repo, :public) }
+ let(:user) { create(:user) }
+
+ context "when signed in as guest" do
+ before do
+ project.add_guest(user)
+ sign_in(user)
+
+ visit(new_project_issue_path(project))
+ end
+
+ it "creates issue" do
+ page.within(".issue-form") do
+ expect(page).to have_no_content("Assign to")
+ .and have_no_content("Labels")
+ .and have_no_content("Milestone")
+
+ expect(page.find('#issue_title')['placeholder']).to eq 'Title'
+ expect(page.find('#issue_description')['placeholder']).to eq 'Write a comment or drag your files here…'
+ end
+
+ issue_title = "500 error on profile"
+
+ fill_in("Title", with: issue_title)
+ click_button("Submit issue")
+
+ expect(page).to have_content(issue_title)
+ .and have_content(user.name)
+ .and have_content(project.name)
+ end
+ end
+
+ context "when signed in as developer", :js do
+ before do
+ project.add_developer(user)
+ sign_in(user)
+
+ visit(new_project_issue_path(project))
+ end
+
+ context "when previewing" do
+ it "previews content" do
+ form = first(".gfm-form")
+ textarea = first(".gfm-form textarea")
+
+ page.within(form) do
+ click_link("Preview")
+
+ preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked.
+
+ expect(preview).to have_content("Nothing to preview.")
+
+ click_link("Write")
+ fill_in("Description", with: "Bug fixed :smile:")
+ click_link("Preview")
+
+ expect(preview).to have_css("gl-emoji")
+ expect(textarea).not_to be_visible
+ end
+ end
+ end
+
+ context "with labels" do
+ LABEL_TITLES = %w(bug feature enhancement).freeze
+
+ before do
+ LABEL_TITLES.each do |title|
+ create(:label, project: project, title: title)
+ end
+ end
+
+ it "creates issue" do
+ issue_title = "500 error on profile"
+
+ fill_in("Title", with: issue_title)
+ click_button("Label")
+ click_link(LABEL_TITLES.first)
+ click_button("Submit issue")
+
+ expect(page).to have_content(issue_title)
+ .and have_content(user.name)
+ .and have_content(project.name)
+ .and have_content(LABEL_TITLES.first)
+ end
+ end
+ end
+end