diff options
author | Vitaliy @blackst0ne Klachkov <blackst0ne.ru@gmail.com> | 2017-09-18 18:52:28 +1100 |
---|---|---|
committer | Vitaliy @blackst0ne Klachkov <blackst0ne.ru@gmail.com> | 2017-09-18 18:52:28 +1100 |
commit | 5d3165d41e04af6b3f188c96bb868a886c1b6145 (patch) | |
tree | 071eed39d114a48024c4c712ea58f192729ec26c /spec | |
parent | 2defc7b931ac46603780944907d7e19233ad1e97 (diff) | |
download | gitlab-ce-5d3165d41e04af6b3f188c96bb868a886c1b6145.tar.gz |
Replace the 'project/snippets.feature' spinach test with an rspec analog
Diffstat (limited to 'spec')
4 files changed, 90 insertions, 0 deletions
diff --git a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb new file mode 100644 index 00000000000..1bd2098af6d --- /dev/null +++ b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe 'User comments on a snippet', :js do + let(:project) { create(:project) } + let!(:snippet) { create(:project_snippet, project: project, author: user) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + + visit(project_snippet_path(project, snippet)) + end + + it 'leaves a comment on a snippet' do + page.within('.js-main-target-form') do + fill_in('note_note', with: 'Good snippet!') + click_button('Comment') + end + + wait_for_requests + + expect(page).to have_content('Good snippet!') + end +end diff --git a/spec/features/projects/snippets/user_deletes_snippet_spec.rb b/spec/features/projects/snippets/user_deletes_snippet_spec.rb new file mode 100644 index 00000000000..ca5f7981c33 --- /dev/null +++ b/spec/features/projects/snippets/user_deletes_snippet_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe 'User deletes a snippet' do + let(:project) { create(:project) } + let!(:snippet) { create(:project_snippet, project: project, author: user) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + + visit(project_snippet_path(project, snippet)) + end + + it 'deletes a snippet' do + first(:link, 'Delete').click + + expect(page).not_to have_content(snippet.title) + end +end diff --git a/spec/features/projects/snippets/user_updates_snippet_spec.rb b/spec/features/projects/snippets/user_updates_snippet_spec.rb new file mode 100644 index 00000000000..09a390443cf --- /dev/null +++ b/spec/features/projects/snippets/user_updates_snippet_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +describe 'User updates a snippet' do + let(:project) { create(:project) } + let!(:snippet) { create(:project_snippet, project: project, author: user) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + + visit(project_snippet_path(project, snippet)) + end + + it 'updates a snippet' do + page.within('.detail-page-header') do + first(:link, 'Edit').click + end + + fill_in('project_snippet_title', with: 'Snippet new title') + click_button('Save') + + expect(page).to have_content('Snippet new title') + end +end diff --git a/spec/features/projects/snippets/user_views_snippets_spec.rb b/spec/features/projects/snippets/user_views_snippets_spec.rb new file mode 100644 index 00000000000..e9992e00ca8 --- /dev/null +++ b/spec/features/projects/snippets/user_views_snippets_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe 'User views snippets' do + let(:project) { create(:project) } + let!(:project_snippet) { create(:project_snippet, project: project, author: user) } + let!(:snippet) { create(:snippet, author: user) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + + visit(project_snippets_path(project)) + end + + it 'shows snippets' do + expect(page).to have_content(project_snippet.title) + expect(page).not_to have_content(snippet.title) + end +end |