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
|
|
|
|
|
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
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click link "New Snippet"' do
|
2013-03-24 14:31:14 -04:00
|
|
|
click_link "Add new snippet"
|
|
|
|
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-06-12 01:36:00 -04:00
|
|
|
page.within ".file-title" do
|
2013-03-24 14:31:14 -04:00
|
|
|
click_link "Edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click link "Remove Snippet"' do
|
2014-06-14 05:36:46 -04:00
|
|
|
click_link "remove"
|
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
|
2013-03-24 14:31:14 -04:00
|
|
|
find(:xpath, "//input[@id='project_snippet_content']").set 'Content of snippet three'
|
|
|
|
end
|
2013-08-12 05:08:52 -04:00
|
|
|
click_button "Create snippet"
|
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!"
|
|
|
|
click_button "Add Comment"
|
|
|
|
end
|
|
|
|
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
|
2015-01-24 13:02:58 -05:00
|
|
|
visit namespace_project_snippet_path(project.namespace, 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
|