diff options
author | Imre Farkas <ifarkas@gitlab.com> | 2018-07-03 14:58:03 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-07-03 14:58:03 +0300 |
commit | 825b9435eddd86adb3fd76f87129c9bffba0315f (patch) | |
tree | f4e1384e7f572735ff1b069e9099b6c10ada166a /spec/features/projects/show | |
parent | 7054ead450c33567d910b99c86c99d7e3ebbae1b (diff) |
Add readme button to non-empty project page
Diffstat (limited to 'spec/features/projects/show')
-rw-r--r-- | spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb index e44361fbe26..7b9242f0631 100644 --- a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb +++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb @@ -5,6 +5,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do # see spec/features/projects/files/project_owner_creates_license_file_spec.rb # see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb + include FakeBlobHelpers + let(:user) { create(:user) } describe 'empty project' do @@ -141,11 +143,57 @@ describe 'Projects > Show > User sees setup shortcut buttons' do allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false) project.add_master(user) sign_in(user) + end - visit project_path(project) + context 'Readme button' do + before do + allow(Project).to receive(:find_by_full_path) + .with(project.full_path, follow_redirects: true) + .and_return(project) + end + + context 'when the project has a populated Readme' do + it 'show the "Readme" anchor' do + visit project_path(project) + + expect(project.repository.readme).not_to be_nil + + page.within('.project-stats') do + expect(page).not_to have_link('Add Readme', href: presenter.add_readme_path) + expect(page).to have_link('Readme', href: presenter.readme_path) + end + end + + context 'when the project has an empty Readme' do + it 'show the "Readme" anchor' do + allow(project.repository).to receive(:readme).and_return(fake_blob(path: 'README.md', data: '', size: 0)) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).not_to have_link('Add Readme', href: presenter.add_readme_path) + expect(page).to have_link('Readme', href: presenter.readme_path) + end + end + end + end + + context 'when the project does not have a Readme' do + it 'shows the "Add Readme" button' do + allow(project.repository).to receive(:readme).and_return(nil) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_link('Add Readme', href: presenter.add_readme_path) + end + end + end end it 'no "Add Changelog" button if the project already has a changelog' do + visit project_path(project) + expect(project.repository.changelog).not_to be_nil page.within('.project-stats') do @@ -154,6 +202,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do end it 'no "Add License" button if the project already has a license' do + visit project_path(project) + expect(project.repository.license_blob).not_to be_nil page.within('.project-stats') do @@ -162,6 +212,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do end it 'no "Add Contribution guide" button if the project already has a contribution guide' do + visit project_path(project) + expect(project.repository.contribution_guide).not_to be_nil page.within('.project-stats') do @@ -171,6 +223,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do describe 'GitLab CI configuration button' do it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do + visit project_path(project) + expect(project.repository.gitlab_ci_yml).to be_nil page.within('.project-stats') do @@ -211,6 +265,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do describe 'Auto DevOps button' do it '"Enable Auto DevOps" button linked to settings page' do + visit project_path(project) + page.within('.project-stats') do expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) end @@ -263,6 +319,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do describe 'Kubernetes cluster button' do it '"Add Kubernetes cluster" button linked to clusters page' do + visit project_path(project) + page.within('.project-stats') do expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project)) end |