diff options
author | Andrew8xx8 <avk@8xx8.ru> | 2013-03-25 02:17:38 +0400 |
---|---|---|
committer | Andrew8xx8 <avk@8xx8.ru> | 2013-03-25 02:19:40 +0400 |
commit | 8f08fbfd9f768b885c631bdc8bc8ad202c6827a0 (patch) | |
tree | dfbdebbc19d0de48b42b47e5f1b6435db800d0a5 /features | |
parent | 4be12be62a9dc30faecff139684f7537f0726d45 (diff) | |
download | gitlab-ce-8f08fbfd9f768b885c631bdc8bc8ad202c6827a0.tar.gz |
Tests for personal snippets added
Diffstat (limited to 'features')
-rw-r--r-- | features/snippets/discover_snippets.feature | 10 | ||||
-rw-r--r-- | features/snippets/snippets.feature | 28 | ||||
-rw-r--r-- | features/snippets/user_snippets.feature | 22 | ||||
-rw-r--r-- | features/steps/shared/paths.rb | 8 | ||||
-rw-r--r-- | features/steps/shared/snippet.rb | 19 | ||||
-rw-r--r-- | features/steps/snippets/discover_snippets.rb | 17 | ||||
-rw-r--r-- | features/steps/snippets/snippets.rb | 64 | ||||
-rw-r--r-- | features/steps/snippets/user_snippets.rb | 41 |
8 files changed, 209 insertions, 0 deletions
diff --git a/features/snippets/discover_snippets.feature b/features/snippets/discover_snippets.feature new file mode 100644 index 00000000000..d6fd2cd7808 --- /dev/null +++ b/features/snippets/discover_snippets.feature @@ -0,0 +1,10 @@ +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 diff --git a/features/snippets/snippets.feature b/features/snippets/snippets.feature new file mode 100644 index 00000000000..ebb4a7c0719 --- /dev/null +++ b/features/snippets/snippets.feature @@ -0,0 +1,28 @@ +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 diff --git a/features/snippets/user_snippets.feature b/features/snippets/user_snippets.feature new file mode 100644 index 00000000000..4c8a91501c4 --- /dev/null +++ b/features/snippets/user_snippets.feature @@ -0,0 +1,22 @@ +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 diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index 42004df426e..08da0908384 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -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 diff --git a/features/steps/shared/snippet.rb b/features/steps/shared/snippet.rb new file mode 100644 index 00000000000..32cc68c2852 --- /dev/null +++ b/features/steps/shared/snippet.rb @@ -0,0 +1,19 @@ +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 diff --git a/features/steps/snippets/discover_snippets.rb b/features/steps/snippets/discover_snippets.rb new file mode 100644 index 00000000000..ff2e4952c36 --- /dev/null +++ b/features/steps/snippets/discover_snippets.rb @@ -0,0 +1,17 @@ +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 diff --git a/features/steps/snippets/snippets.rb b/features/steps/snippets/snippets.rb new file mode 100644 index 00000000000..87a499821dd --- /dev/null +++ b/features/steps/snippets/snippets.rb @@ -0,0 +1,64 @@ +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 diff --git a/features/steps/snippets/user_snippets.rb b/features/steps/snippets/user_snippets.rb new file mode 100644 index 00000000000..0920b56e38d --- /dev/null +++ b/features/steps/snippets/user_snippets.rb @@ -0,0 +1,41 @@ +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 |