2014-10-02 12:42:54 -04:00
|
|
|
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
|
2017-04-13 12:47:28 -04:00
|
|
|
include WaitForAjax
|
2013-03-24 18:17:38 -04:00
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I click link "Personal snippet one"' do
|
2013-03-24 18:17:38 -04:00
|
|
|
click_link "Personal snippet one"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should not see "Personal snippet one" in snippets' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).not_to have_content "Personal snippet one"
|
2013-03-24 18:17:38 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
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
|
|
|
|
|
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 18:17:38 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I submit new snippet "Personal snippet three"' do
|
2015-06-22 08:21:34 -04:00
|
|
|
fill_in "personal_snippet_title", with: "Personal snippet three"
|
|
|
|
fill_in "personal_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 18:17:38 -04:00
|
|
|
end
|
2013-07-18 06:08:48 -04:00
|
|
|
click_button "Create snippet"
|
2017-04-13 12:47:28 -04:00
|
|
|
wait_for_ajax
|
2013-03-24 18:17:38 -04:00
|
|
|
end
|
|
|
|
|
2015-06-20 00:18:24 -04:00
|
|
|
step 'I submit new internal snippet' do
|
2015-06-22 08:21:34 -04:00
|
|
|
fill_in "personal_snippet_title", with: "Internal personal snippet one"
|
|
|
|
fill_in "personal_snippet_file_name", with: "my_snippet.rb"
|
2015-06-20 00:18:24 -04:00
|
|
|
choose 'personal_snippet_visibility_level_10'
|
|
|
|
|
|
|
|
page.within('.file-editor') do
|
2015-06-22 08:21:34 -04:00
|
|
|
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of internal snippet'
|
2015-06-20 00:18:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
click_button "Create snippet"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see snippet "Personal snippet three"' do
|
2015-06-12 00:44:13 -04:00
|
|
|
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
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I submit new title "Personal snippet new title"' do
|
2015-06-22 08:21:34 -04:00
|
|
|
fill_in "personal_snippet_title", with: "Personal snippet new title"
|
2013-03-24 18:17:38 -04:00
|
|
|
click_button "Save"
|
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see "Personal snippet new title"' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_content "Personal snippet new title"
|
2013-03-24 18:17:38 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
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
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I should see "Personal snippet one" public' do
|
2015-06-12 00:44:13 -04:00
|
|
|
expect(page).to have_no_xpath("//i[@class='public-snippet']")
|
2013-03-24 18:17:38 -04:00
|
|
|
end
|
|
|
|
|
2014-09-21 17:40:22 -04:00
|
|
|
step 'I visit snippet page "Personal snippet one"' do
|
2013-03-24 18:17:38 -04:00
|
|
|
visit snippet_path(snippet)
|
|
|
|
end
|
|
|
|
|
2015-06-20 00:18:24 -04:00
|
|
|
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
|
2015-06-20 00:18:24 -04:00
|
|
|
|
|
|
|
def internal_snippet
|
|
|
|
@snippet ||= PersonalSnippet.find_by!(title: "Internal personal snippet one")
|
|
|
|
end
|
2013-03-24 18:17:38 -04:00
|
|
|
end
|