diff options
author | Semyon Pupkov <mail@semyonpupkov.com> | 2018-01-20 14:37:36 +0500 |
---|---|---|
committer | Semyon Pupkov <mail@semyonpupkov.com> | 2018-01-25 11:14:57 +0500 |
commit | 021fcebc2840e5ff1ad95d5eae7506440084be75 (patch) | |
tree | b68049eee00de8fe645945cc457f9cb5b4d9e8dc /spec | |
parent | 8f5d1d1371b47ab810a9e5ddff483f669d149363 (diff) | |
download | gitlab-ce-021fcebc2840e5ff1ad95d5eae7506440084be75.tar.gz |
Move user page spinach tests to RSpec
https://gitlab.com/gitlab-org/gitlab-ce/issues/23036
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/user_page_spec.rb | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/spec/features/user_page_spec.rb b/spec/features/user_page_spec.rb new file mode 100644 index 00000000000..19c587e53c8 --- /dev/null +++ b/spec/features/user_page_spec.rb @@ -0,0 +1,107 @@ +require 'spec_helper' + +describe 'User page', :js do + let!(:user) { create :user } + let!(:private_project) do + create :project, :private, name: 'private', namespace: user.namespace do |project| + project.add_master(user) + end + end + + let!(:internal_project) do + create :project, :internal, name: 'internal', namespace: user.namespace do |project| + project.add_master(user) + end + end + + let!(:public_project) do + create :project, :public, name: 'public', namespace: user.namespace do |project| + project.add_master(user) + end + end + + def click_nav_link(name) + page.within '.nav-links' do + click_link name + end + end + + context 'when not signed in' do + it 'renders user public project' do + visit user_path(user) + click_nav_link('Personal projects') + + expect(page).to have_css('.tab-content #projects.active') + expect(title).to start_with(user.name) + + expect(page).to have_content(public_project.name) + expect(page).not_to have_content(private_project.name) + expect(page).not_to have_content(internal_project.name) + end + end + + context 'when signed in as another user' do + let(:another_user) { create :user } + + before do + sign_in(another_user) + end + + it 'renders user public and internal projects' do + visit user_path(user) + click_nav_link('Personal projects') + + expect(title).to start_with(user.name) + + expect(page).not_to have_content(private_project.name) + expect(page).to have_content(public_project.name) + expect(page).to have_content(internal_project.name) + end + end + + context 'when signed in as user' do + before do + sign_in(user) + end + + describe 'personal projects' do + it 'renders all user projects' do + visit user_path(user) + click_nav_link('Personal projects') + + expect(title).to start_with(user.name) + + expect(page).to have_content(private_project.name) + expect(page).to have_content(public_project.name) + expect(page).to have_content(internal_project.name) + end + end + + describe 'contributed projects' do + context 'when user has contributions' do + let(:contributed_project) do + create :project, :public, :empty_repo + end + + before do + Issues::CreateService.new(contributed_project, user, { title: 'Bug in old browser' }).execute + event = create(:push_event, project: contributed_project, author: user) + create(:push_event_payload, event: event, commit_count: 3) + end + + it 'renders contributed project' do + visit user_path(user) + + expect(title).to start_with(user.name) + expect(page).to have_css('.js-contrib-calendar') + + click_nav_link('Contributed projects') + + page.within '#contributed' do + expect(page).to have_content(contributed_project.name) + end + end + end + end + end +end |