BigW Consortium Gitlab

snippets.rb 2.39 KB
Newer Older
1
class Spinach::Features::Snippets < Spinach::FeatureSteps
2 3 4
  include SharedAuthentication
  include SharedPaths
  include SharedProject
Andrew8xx8 committed
5
  include SharedSnippet
6

7
  step 'I click link "Personal snippet one"' do
8 9 10
    click_link "Personal snippet one"
  end

11
  step 'I should not see "Personal snippet one" in snippets' do
12
    expect(page).not_to have_content "Personal snippet one"
13 14
  end

15
  step 'I click link "Edit"' do
Douwe Maan committed
16
    page.within ".detail-page-header" do
17 18 19 20
      click_link "Edit"
    end
  end

21 22
  step 'I click link "Delete"' do
    click_link "Delete"
23 24
  end

25
  step 'I submit new snippet "Personal snippet three"' do
26 27
    fill_in "personal_snippet_title", with: "Personal snippet three"
    fill_in "personal_snippet_file_name", with: "my_snippet.rb"
28
    page.within('.file-editor') do
29 30
      find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
    end
31
    click_button "Create snippet"
32 33
  end

34
  step 'I submit new internal snippet' do
35 36
    fill_in "personal_snippet_title", with: "Internal personal snippet one"
    fill_in "personal_snippet_file_name", with: "my_snippet.rb"
37 38 39
    choose 'personal_snippet_visibility_level_10'

    page.within('.file-editor') do
40
      find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of internal snippet'
41 42 43 44 45
    end

    click_button "Create snippet"
  end

46
  step 'I should see snippet "Personal snippet three"' do
47 48
    expect(page).to have_content "Personal snippet three"
    expect(page).to have_content "Content of snippet three"
49 50
  end

51
  step 'I submit new title "Personal snippet new title"' do
52
    fill_in "personal_snippet_title", with: "Personal snippet new title"
53 54 55
    click_button "Save"
  end

56
  step 'I should see "Personal snippet new title"' do
57
    expect(page).to have_content "Personal snippet new title"
58 59
  end

60
  step 'I uncheck "Private" checkbox' do
61
    choose "Internal"
62 63 64
    click_button "Save"
  end

65
  step 'I should see "Personal snippet one" public' do
66
    expect(page).to have_no_xpath("//i[@class='public-snippet']")
67 68
  end

69
  step 'I visit snippet page "Personal snippet one"' do
70 71 72
    visit snippet_path(snippet)
  end

73 74 75 76
  step 'I visit snippet page "Internal personal snippet one"' do
    visit snippet_path(internal_snippet)
  end

77
  def snippet
skv committed
78
    @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one")
79
  end
80 81 82 83

  def internal_snippet
    @snippet ||= PersonalSnippet.find_by!(title: "Internal personal snippet one")
  end
84
end