gitlab-org--gitlab-foss/features/steps/snippets/snippets.rb

85 lines
2.4 KiB
Ruby
Raw Normal View History

class Spinach::Features::Snippets < Spinach::FeatureSteps
2013-03-24 18:17:38 -04:00
include SharedAuthentication
include SharedPaths
include SharedProject
2013-03-25 05:14:12 -04:00
include SharedSnippet
2013-03-24 18:17:38 -04:00
step 'I click link "Personal snippet one"' do
2013-03-24 18:17:38 -04:00
click_link "Personal snippet one"
end
step 'I should not see "Personal snippet one" in snippets' do
expect(page).not_to have_content "Personal snippet one"
2013-03-24 18:17:38 -04:00
end
step 'I click link "Edit"' do
2015-12-16 11:07:02 -05:00
page.within ".detail-page-header" do
2016-05-19 05:01:27 -04:00
first(:link, "Edit").click
2013-03-24 18:17:38 -04:00
end
end
step 'I click link "Delete"' do
2016-05-19 05:01:27 -04:00
first(:link, "Delete").click
2013-03-24 18:17:38 -04:00
end
step 'I submit new snippet "Personal snippet three"' do
fill_in "personal_snippet_title", with: "Personal snippet three"
fill_in "personal_snippet_file_name", with: "my_snippet.rb"
page.within('.file-editor') do
2013-03-24 18:17:38 -04:00
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
end
click_button "Create snippet"
2013-03-24 18:17:38 -04:00
end
step 'I submit new internal snippet' do
fill_in "personal_snippet_title", with: "Internal personal snippet one"
fill_in "personal_snippet_file_name", with: "my_snippet.rb"
choose 'personal_snippet_visibility_level_10'
page.within('.file-editor') do
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of internal snippet'
end
click_button "Create snippet"
end
step 'I should see snippet "Personal snippet three"' do
expect(page).to have_content "Personal snippet three"
expect(page).to have_content "Content of snippet three"
2013-03-24 18:17:38 -04:00
end
step 'I submit new title "Personal snippet new title"' do
fill_in "personal_snippet_title", with: "Personal snippet new title"
2013-03-24 18:17:38 -04:00
click_button "Save"
end
step 'I should see "Personal snippet new title"' do
expect(page).to have_content "Personal snippet new title"
2013-03-24 18:17:38 -04:00
end
step 'I uncheck "Private" checkbox' do
2014-10-07 04:54:00 -04:00
choose "Internal"
2013-03-24 18:17:38 -04:00
click_button "Save"
end
step 'I should see "Personal snippet one" public' do
expect(page).to have_no_xpath("//i[@class='public-snippet']")
2013-03-24 18:17:38 -04:00
end
step 'I visit snippet page "Personal snippet one"' do
2013-03-24 18:17:38 -04:00
visit snippet_path(snippet)
end
step 'I visit snippet page "Internal personal snippet one"' do
visit snippet_path(internal_snippet)
end
2013-03-24 18:17:38 -04:00
def snippet
2014-01-19 13:55:59 -05:00
@snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one")
2013-03-24 18:17:38 -04:00
end
def internal_snippet
@snippet ||= PersonalSnippet.find_by!(title: "Internal personal snippet one")
end
2013-03-24 18:17:38 -04:00
end