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

85 lines
2.4 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
class Spinach::Features::Snippets < Spinach::FeatureSteps
2014-09-02 18:07:02 +05:30
include SharedAuthentication
include SharedPaths
include SharedProject
include SharedSnippet
2015-04-26 12:48:37 +05:30
step 'I click link "Personal snippet one"' do
2014-09-02 18:07:02 +05:30
click_link "Personal snippet one"
end
2015-04-26 12:48:37 +05:30
step 'I should not see "Personal snippet one" in snippets' do
2015-09-11 14:41:01 +05:30
expect(page).not_to have_content "Personal 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-11-26 14:37:03 +05:30
page.within ".page-title" 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 "Personal snippet three"' do
2015-09-11 14:41:01 +05:30
fill_in "personal_snippet_title", with: "Personal snippet three"
fill_in "personal_snippet_file_name", with: "my_snippet.rb"
page.within('.file-editor') do
2014-09-02 18:07:02 +05:30
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
end
click_button "Create snippet"
end
2015-09-11 14:41:01 +05:30
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
2015-04-26 12:48:37 +05:30
step 'I should see snippet "Personal snippet three"' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Personal 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 "Personal snippet new title"' do
2015-09-11 14:41:01 +05:30
fill_in "personal_snippet_title", with: "Personal 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 "Personal snippet new title"' do
2015-09-11 14:41:01 +05:30
expect(page).to have_content "Personal snippet new title"
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I uncheck "Private" checkbox' do
choose "Internal"
2014-09-02 18:07:02 +05:30
click_button "Save"
end
2015-04-26 12:48:37 +05:30
step 'I should see "Personal snippet one" public' do
2015-09-11 14:41:01 +05:30
expect(page).to have_no_xpath("//i[@class='public-snippet']")
2014-09-02 18:07:02 +05:30
end
2015-04-26 12:48:37 +05:30
step 'I visit snippet page "Personal snippet one"' do
2014-09-02 18:07:02 +05:30
visit snippet_path(snippet)
end
2015-09-11 14:41:01 +05:30
step 'I visit snippet page "Internal personal snippet one"' do
visit snippet_path(internal_snippet)
end
2014-09-02 18:07:02 +05:30
def snippet
@snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one")
end
2015-09-11 14:41:01 +05:30
def internal_snippet
@snippet ||= PersonalSnippet.find_by!(title: "Internal personal snippet one")
end
2014-09-02 18:07:02 +05:30
end