Commit 8f08fbfd authored by Andrew8xx8's avatar Andrew8xx8

Tests for personal snippets added

parent 4be12be6
Feature: Discover Snippets
Background:
Given I sign in as a user
And I have public "Personal snippet one" snippet
And I have private "Personal snippet private" snippet
Scenario: I should see snippets
Given I visit snippets page
Then I should see "Personal snippet one" in snippets
And I should not see "Personal snippet private" in snippets
Feature: Snippets
Background:
Given I sign in as a user
And I have public "Personal snippet one" snippet
And I have private "Personal snippet private" snippet
Scenario: I create new snippet
Given I visit new snippet page
And I submit new snippet "Personal snippet three"
Then I should see snippet "Personal snippet three"
Scenario: I update "Personal snippet one"
Given I visit snippet page "Personal snippet one"
And I click link "Edit"
And I submit new title "Personal snippet new title"
Then I should see "Personal snippet new title"
Scenario: Set "Personal snippet one" public
Given I visit snippet page "Personal snippet one"
And I click link "Edit"
And I uncheck "Private" checkbox
Then I should see "Personal snippet one" public
Scenario: I destroy "Personal snippet one"
Given I visit snippet page "Personal snippet one"
And I click link "Edit"
And I click link "Destroy"
Then I should not see "Personal snippet one" in snippets
Feature: User Snippets
Background:
Given I sign in as a user
And I have public "Personal snippet one" snippet
And I have private "Personal snippet private" snippet
Scenario: I should see all my snippets
Given I visit my snippets page
Then I should see "Personal snippet one" in snippets
And I should see "Personal snippet private" in snippets
Scenario: I can see only my private snippets
Given I visit my snippets page
And I click "Private" filter
Then I should not see "Personal snippet one" in snippets
And I should see "Personal snippet private" in snippets
Scenario: I can see only my public snippets
Given I visit my snippets page
And I click "Public" filter
Then I should see "Personal snippet one" in snippets
And I should not see "Personal snippet private" in snippets
......@@ -267,6 +267,14 @@ module SharedPaths
visit project_snippets_path(project)
end
Given 'I visit snippets page' do
visit snippets_path
end
Given 'I visit new snippet page' do
visit new_snippet_path
end
def root_ref
@project.repository.root_ref
end
......
module SharedProject
And 'I have public "Personal snippet one" snippet' do
create(:personal_snippet,
title: "Personal snippet one",
content: "Test content",
file_name: "snippet.rb",
private: false,
author: current_user)
end
And 'I have private "Personal snippet private" snippet' do
create(:personal_snippet,
title: "Personal snippet private",
content: "Provate content",
file_name: "private_snippet.rb",
private: true,
author: current_user)
end
end
class DiscoverSnippets < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
Then 'I should see "Personal snippet one" in snippets' do
page.should have_content "Personal snippet one"
end
And 'I should not see "Personal snippet private" in snippets' do
page.should_not have_content "Personal snippet private"
end
def snippet
@snippet ||= PersonalSnippet.find_by_title!("Personal snippet one")
end
end
class Snippets < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
Given 'I click link "Personal snippet one"' do
click_link "Personal snippet one"
end
And 'I should not see "Personal snippet one" in snippets' do
page.should_not have_content "Personal snippet one"
end
And 'I click link "Edit"' do
within ".page_title" do
click_link "Edit"
end
end
And 'I click link "Destroy"' do
click_link "Destroy"
end
And 'I submit new snippet "Personal snippet three"' do
fill_in "personal_snippet_title", :with => "Personal snippet three"
select "forever", :from => "personal_snippet_expires_at"
fill_in "personal_snippet_file_name", :with => "my_snippet.rb"
within('.file-editor') do
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
end
click_button "Save"
end
Then 'I should see snippet "Personal snippet three"' do
page.should have_content "Personal snippet three"
page.should have_content "Content of snippet three"
end
And 'I submit new title "Personal snippet new title"' do
fill_in "personal_snippet_title", :with => "Personal snippet new title"
click_button "Save"
end
Then 'I should see "Personal snippet new title"' do
page.should have_content "Personal snippet new title"
end
And 'I uncheck "Private" checkbox' do
find(:xpath, "//input[@id='personal_snippet_private']").set true
click_button "Save"
end
Then 'I should see "Personal snippet one" public' do
page.should have_selector(:xpath, "//i[@class='public-snippet']")
end
And 'I visit snippet page "Personal snippet one"' do
visit snippet_path(snippet)
end
def snippet
@snippet ||= PersonalSnippet.find_by_title!("Personal snippet one")
end
end
class UserSnippets < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
Given 'I visit my snippets page' do
visit user_snippets_path(current_user)
end
Then 'I should see "Personal snippet one" in snippets' do
page.should have_content "Personal snippet one"
end
And 'I should see "Personal snippet private" in snippets' do
page.should have_content "Personal snippet private"
end
Then 'I should not see "Personal snippet one" in snippets' do
page.should_not have_content "Personal snippet one"
end
And 'I should not see "Personal snippet private" in snippets' do
page.should_not have_content "Personal snippet private"
end
Given 'I click "Public" filter' do
within('.nav-stacked') do
click_link "Public"
end
end
Given 'I click "Private" filter' do
within('.nav-stacked') do
click_link "Private"
end
end
def snippet
@snippet ||= PersonalSnippet.find_by_title!("Personal snippet one")
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment