Commit 84edc9a2 authored by Kamil Trzcinski's avatar Kamil Trzcinski Committed by James Edwards-Jones

Added spinach tests

parent db35f3dc
......@@ -81,10 +81,6 @@ module ProjectsHelper
"You are going to remove the fork relationship to source project #{@project.forked_from_project.name_with_namespace}. Are you ABSOLUTELY sure?"
end
def remove_pages_message(project)
"You are going to remove the pages for #{project.name_with_namespace}.\n Are you ABSOLUTELY sure?"
end
def project_nav_tabs
@nav_tabs ||= get_project_nav_tabs(@project, current_user)
end
......
......@@ -3,8 +3,7 @@
.panel-heading Remove pages
.errors-holder
.panel-body
= form_tag(remove_pages_namespace_project_pages_path(@project.namespace, @project), method: :delete, class: 'form-horizontal') do
%p
Removing the pages will prevent from exposing them to outside world.
.form-actions
= button_to 'Remove pages', '#', class: "btn btn-remove js-confirm-danger", data: { "confirm-danger-message" => remove_pages_message(@project) }
%p
Removing the pages will prevent from exposing them to outside world.
.form-actions
= link_to 'Remove', remove_pages_namespace_project_pages_path(@project.namespace, @project), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove"
......@@ -12,7 +12,7 @@
= f.text_field :domain, required: true, autocomplete: 'off', class: 'form-control'
%span.help-inline * required
- if Settings.pages.external_https
- if Gitlab.config.pages.external_https
.form-group
= f.label :certificate, class: 'control-label' do
Certificate (PEM)
......
......@@ -2,7 +2,7 @@
%h3.page_title
Pages
- if Settings.pages.external_http || Settings.pages.external_https
- if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
= link_to new_namespace_project_page_path(@project.namespace, @project), class: "btn btn-new pull-right", title: "New Domain" do
%i.fa.fa-plus
New Domain
......@@ -14,10 +14,10 @@
%hr.clearfix
- if Settings.pages.enabled
- if Gitlab.config.pages.enabled
= render 'access'
= render 'use'
- if Settings.pages.external_http || Settings.pages.external_https
- if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
= render 'list'
- else
= render 'no_domains'
......
Feature: Project Pages
Background:
Given I sign in as a user
And I own a project
Scenario: Pages are disabled
Given pages are disabled
When I visit the Project Pages
Then I should see that GitLab Pages are disabled
Scenario: I can see the pages usage if not deployed
Given pages are enabled
When I visit the Project Pages
Then I should see the usage of GitLab Pages
Scenario: I can access the pages if deployed
Given pages are enabled
And pages are deployed
When I visit the Project Pages
Then I should be able to access the Pages
Scenario: I should message that domains support is disabled
Given pages are enabled
And pages are deployed
And support for external domains is disabled
When I visit the Project Pages
Then I should see that support for domains is disabled
Scenario: I should see a new domain button
Given pages are enabled
And pages are exposed on external HTTP address
When I visit the Project Pages
And I should be able to add a New Domain
Scenario: I should be able to add a new domain
Given pages are enabled
And pages are exposed on external HTTP address
When I visit add a new Pages Domain
And I fill the domain
And I click on "Create New Domain"
Then I should see a new domain added
Scenario: I should be denied to add the same domain twice
Given pages are enabled
And pages are exposed on external HTTP address
And pages domain is added
When I visit add a new Pages Domain
And I fill the domain
And I click on "Create New Domain"
Then I should see error message that domain already exists
Scenario: I should message that certificates support is disabled when trying to add a new domain
Given pages are enabled
And pages are exposed on external HTTP address
And pages domain is added
When I visit add a new Pages Domain
Then I should see that support for certificates is disabled
Scenario: I should be able to add a new domain with certificate
Given pages are enabled
And pages are exposed on external HTTPS address
When I visit add a new Pages Domain
And I fill the domain
And I fill the certificate and key
And I click on "Create New Domain"
Then I should see a new domain added
Scenario: I can remove the pages if deployed
Given pages are enabled
And pages are deployed
When I visit the Project Pages
And I click Remove Pages
Then The Pages should get removed
class Spinach::Features::ProjectPages < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
step 'pages are enabled' do
Gitlab.config.pages.stub(:enabled).and_return(true)
Gitlab.config.pages.stub(:host).and_return('example.com')
Gitlab.config.pages.stub(:port).and_return(80)
Gitlab.config.pages.stub(:https).and_return(false)
end
step 'pages are disabled' do
Gitlab.config.pages.stub(:enabled).and_return(false)
end
step 'I visit the Project Pages' do
visit namespace_project_pages_path(@project.namespace, @project)
end
step 'I should see that GitLab Pages are disabled' do
expect(page).to have_content('GitLab Pages are disabled')
end
step 'I should see the usage of GitLab Pages' do
expect(page).to have_content('Configure pages')
end
step 'pages are deployed' do
commit = @project.ensure_ci_commit(@project.commit('HEAD').sha)
build = build(:ci_build,
project: @project,
commit: commit,
ref: 'HEAD',
artifacts_file: fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip'),
artifacts_metadata: fixture_file_upload(Rails.root + 'spec/fixtures/pages.zip.meta')
)
result = ::Projects::UpdatePagesService.new(@project, build).execute
expect(result[:status]).to eq(:success)
end
step 'I should be able to access the Pages' do
expect(page).to have_content('Access pages')
end
step 'I should see that support for domains is disabled' do
expect(page).to have_content('Support for domains and certificates is disabled')
end
step 'support for external domains is disabled' do
Gitlab.config.pages.stub(:external_http).and_return(nil)
Gitlab.config.pages.stub(:external_https).and_return(nil)
end
step 'pages are exposed on external HTTP address' do
Gitlab.config.pages.stub(:external_http).and_return('1.1.1.1:80')
Gitlab.config.pages.stub(:external_https).and_return(nil)
end
step 'pages are exposed on external HTTPS address' do
Gitlab.config.pages.stub(:external_http).and_return('1.1.1.1:80')
Gitlab.config.pages.stub(:external_https).and_return('1.1.1.1:443')
end
step 'I should be able to add a New Domain' do
expect(page).to have_content('New Domain')
end
step 'I visit add a new Pages Domain' do
visit new_namespace_project_page_path(@project.namespace, @project)
end
step 'I fill the domain' do
fill_in 'Domain', with: 'my.test.domain.com'
end
step 'I click on "Create New Domain"' do
click_button 'Create New Domain'
end
step 'I should see a new domain added' do
expect(page).to have_content('Domains (1)')
expect(page).to have_content('my.test.domain.com')
end
step 'pages domain is added' do
@project.pages_domains.create!(domain: 'my.test.domain.com')
end
step 'I should see error message that domain already exists' do
expect(page).to have_content('Domain has already been taken')
end
step 'I should see that support for certificates is disabled' do
expect(page).to have_content('Support for custom certificates is disabled')
end
step 'I fill the certificate and key' do
fill_in 'Certificate (PEM)', with: '-----BEGIN CERTIFICATE-----
MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0
LWNlcnRpZmljYXRlMB4XDTE2MDIxM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kXcIjeH6KwQsuR
5vrXfBZ3sQfflaiN4QJBANBt8JY2LIGQF8o89qwUpRL5vbnKQ4IzZ5+TOl4RLR7O
AQpJ81tGuINghO7aunctb6rrcKJrxmEH1whzComybrMCQQDKV49nOBudRBAIgG4K
EnLzsRKISUHMZSJiYTYnablof8cKw1JaQduw7zgrUlLwnroSaAGX88+Jw1f5n2Lh
Vlg5AkBDdUGnrDLtYBCDEQYZHblrkc7ZAeCllDOWjxUV+uMqlCv8A4Ey6omvY57C
m6I8DkWVAQx8VPtozhvHjUw80rZHAkB55HWHAM3h13axKG0htCt7klhPsZHpx6MH
EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx
63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi
nNp/xedE1YxutQ==
-----END PRIVATE KEY-----'
end
step 'I click Remove Pages' do
click_link 'Remove pages'
end
step 'The Pages should get removed' do
expect(@project.pages_url).to be_nil
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