debian-mirror-gitlab/features/steps/project/snippets.rb

96 lines
2.6 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
2014-09-02 18:07:02 +05:30
include SharedAuthentication
include SharedProject
include SharedNote
include SharedPaths
2015-04-26 12:48:37 +05:30
step 'project "Shop" have "Snippet one" snippet' do
2014-09-02 18:07:02 +05:30
create(:project_snippet,
title: "Snippet one",
content: "Test content",
file_name: "snippet.rb",
project: project,
author: project.users.first)
end
2015-04-26 12:48:37 +05:30
step 'project "Shop" have no "Snippet two" snippet' do
2014-09-02 18:07:02 +05:30
create(:snippet,
title: "Snippet two",
content: "Test content",
file_name: "snippet.rb",
author: project.users.first)
end
2015-04-26 12:48:37 +05:30
step 'I click link "New Snippet"' do
2015-11-26 14:37:03 +05:30
click_link "New Snippet"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I click link "Snippet one"' do
2014-09-02 18:07:02 +05:30
click_link "Snippet one"
end
2015-04-26 12:48:37 +05:30
step 'I should see "Snippet one" in snippets' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Snippet one"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I should not see "Snippet two" in snippets' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_content "Snippet two"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I should not see "Snippet one" in snippets' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_content "Snippet one"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I click link "Edit"' do
2015-12-23 02:04:40 +05:30
page.within ".detail-page-header" do
2014-09-02 18:07:02 +05:30
click_link "Edit"
end
end
2015-11-26 14:37:03 +05:30
step 'I click link "Delete"' do
click_link "Delete"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I submit new snippet "Snippet three"' do
2015-09-11 14:41:01 +05:30
fill_in "project_snippet_title", with: "Snippet three"
fill_in "project_snippet_file_name", with: "my_snippet.rb"
page.within('.file-editor') do
2014-09-02 18:07:02 +05:30
find(:xpath, "//input[@id='project_snippet_content']").set 'Content of snippet three'
end
click_button "Create snippet"
end
2015-04-26 12:48:37 +05:30
step 'I should see snippet "Snippet three"' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Snippet three"
expect(page).to have_content "Content of snippet three"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I submit new title "Snippet new title"' do
2015-09-11 14:41:01 +05:30
fill_in "project_snippet_title", with: "Snippet new title"
2014-09-02 18:07:02 +05:30
click_button "Save"
end
2015-04-26 12:48:37 +05:30
step 'I should see "Snippet new title"' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Snippet new title"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I leave a comment like "Good snippet!"' do
2015-09-11 14:41:01 +05:30
page.within('.js-main-target-form') do
2014-09-02 18:07:02 +05:30
fill_in "note_note", with: "Good snippet!"
click_button "Add Comment"
end
end
2015-04-26 12:48:37 +05:30
step 'I should see comment "Good snippet!"' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Good snippet!"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I visit snippet page "Snippet one"' do
visit namespace_project_snippet_path(project.namespace, project, project_snippet)
2014-09-02 18:07:02 +05:30
end
def project_snippet
@project_snippet ||= ProjectSnippet.find_by!(title: "Snippet one")
end
end