2014-09-22 10:30:25 -04:00
|
|
|
class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
|
2013-03-24 14:31:14 -04:00
|
|
|
include SharedAuthentication
|
|
|
|
include SharedProject
|
|
|
|
include SharedNote
|
|
|
|
include SharedPaths
|
2017-05-17 14:25:13 -04:00
|
|
|
include WaitForRequests
|
2013-03-24 14:31:14 -04:00
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'project "Shop" have "Snippet one" snippet' do
|
2013-03-24 14:31:14 -04:00
|
|
|
create(:project_snippet,
|
|
|
|
title: "Snippet one",
|
|
|
|
content: "Test content",
|
|
|
|
file_name: "snippet.rb",
|
|
|
|
project: project,
|
|
|
|
author: project.users.first)
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'project "Shop" have no "Snippet two" snippet' do
|
2013-03-24 14:31:14 -04:00
|
|
|
create(:snippet,
|
|
|
|
title: "Snippet two",
|
|
|
|
content: "Test content",
|
|
|
|
file_name: "snippet.rb",
|
|
|
|
author: project.users.first)
|
|
|
|
end
|
|
|
|
|
2016-09-16 05:37:19 -04:00
|
|
|
step 'I click link "New snippet"' do
|
2017-05-29 05:28:20 -04:00
|
|
|
page.within '#content-body' do
|
|
|
|
first(:link, "New snippet").click
|
|
|
|
end
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click link "Snippet one"' do
|
2013-03-24 14:31:14 -04:00
|
|
|
click_link "Snippet one"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see "Snippet one" in snippets' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Snippet one"
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should not see "Snippet two" in snippets' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).not_to have_content "Snippet two"
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should not see "Snippet one" in snippets' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).not_to have_content "Snippet one"
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click link "Edit"' do
|
2015-12-16 10:13:22 -05:00
|
|
|
page.within ".detail-page-header" do
|
2016-05-19 05:01:27 -04:00
|
|
|
first(:link, "Edit").click
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-10-15 02:01:17 -04:00
|
|
|
step 'I click link "Delete"' do
|
2016-05-19 05:01:27 -04:00
|
|
|
first(:link, "Delete").click
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I submit new snippet "Snippet three"' do
|
2015-06-22 08:21:34 -04:00
|
|
|
fill_in "project_snippet_title", with: "Snippet three"
|
|
|
|
fill_in "project_snippet_file_name", with: "my_snippet.rb"
|
2015-06-12 01:36:00 -04:00
|
|
|
page.within('.file-editor') do
|
2017-04-13 12:47:28 -04:00
|
|
|
find('.ace_editor').native.send_keys 'Content of snippet three'
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
2013-08-12 05:08:52 -04:00
|
|
|
click_button "Create snippet"
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see snippet "Snippet three"' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Snippet three"
|
|
|
|
expect(page).to have_content "Content of snippet three"
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I submit new title "Snippet new title"' do
|
2015-06-22 08:21:34 -04:00
|
|
|
fill_in "project_snippet_title", with: "Snippet new title"
|
2013-03-24 14:31:14 -04:00
|
|
|
click_button "Save"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see "Snippet new title"' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Snippet new title"
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I leave a comment like "Good snippet!"' do
|
2015-06-12 01:36:00 -04:00
|
|
|
page.within('.js-main-target-form') do
|
2013-03-24 14:31:14 -04:00
|
|
|
fill_in "note_note", with: "Good snippet!"
|
2016-03-04 05:44:04 -05:00
|
|
|
click_button "Comment"
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
2017-05-17 14:25:13 -04:00
|
|
|
wait_for_requests
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see comment "Good snippet!"' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Good snippet!"
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I visit snippet page "Snippet one"' do
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_snippet_path(project, project_snippet)
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def project_snippet
|
2014-01-19 13:55:59 -05:00
|
|
|
@project_snippet ||= ProjectSnippet.find_by!(title: "Snippet one")
|
2013-03-24 14:31:14 -04:00
|
|
|
end
|
|
|
|
end
|