Commit db1a6daa authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add some basic feature specs on UI [ci skip]

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 10d65e1b
- @no_container = true
- page_title "Packages"
%div{ class: container_class }
%table.table
%thead
%tr
%th Name
%th Version
%th Files
%th Created at
%tbody
- @packages.each do |package|
%tr
%td
= package.name
%td
= package.version
%td
%ul
- package.package_files.each do |package_file|
%li
= package_file.file
%td
= package.created_at
- page_title "Packages"
%table.table
- if @packages.any?
%table.table
%thead
%tr
%th Name
......@@ -20,4 +21,8 @@
%td
= package.created_at
= paginate @packages, theme: "gitlab"
= paginate @packages, theme: "gitlab"
- else
.nothing-here-block
= _('No packages stored for this project.')
FactoryBot.define do
factory :package, class: Packages::Package do
project
name 'my/company/app/my-app'
version '1-0-SNAPSHOT'
factory :maven_package do
maven_metadatum
after :create do |package|
create :package_file, :xml, package: package
create :package_file, :jar, package: package
create :package_file, :pom, package: package
end
end
end
factory :package_file, class: Packages::PackageFile do
package
trait(:jar) do
file Tempfile.new('my-app-1.0-20180724.124855-1.jar')
file_name 'my-app-1.0-20180724.124855-1.jar'
file_type 'jar'
end
trait(:pom) do
file Tempfile.new('my-app-1.0-20180724.124855-1.pom')
file_name 'my-app-1.0-20180724.124855-1.pom'
file_type 'pom'
end
trait(:xml) do
file Tempfile.new('maven-metadata.xml')
file_name 'maven-metadata.xml'
file_type 'xml'
end
end
factory :maven_metadatum, class: Packages::MavenMetadatum do
package
app_group 'my/company/app'
app_name 'my-app'
app_version '1-0-SNAPSHOT'
end
end
require 'spec_helper'
describe 'Packages' do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:package) { create(:maven_package, project: project) }
before do
sign_in(user)
project.add_developer(user)
stub_packages_config(enabled: true)
end
context 'when there are no packages' do
it 'shows no packages message' do
visit_project_packages
expect(page).to have_content 'No packages stored for this project.'
end
end
context 'when there are packages' do
before do
package
end
it 'shows list of packages' do
visit_project_packages
expect(page).to have_content(package.name)
expect(page).to have_content(package.version)
end
it 'shows a single package' do
visit_project_packages
click_on package.name
expect(page).to have_content(package.name)
expect(page).to have_content(package.version)
package.package_files.each do |package_file|
expect(page).to have_content(package_file.file_name)
end
end
end
def visit_project_packages
visit project_packages_path(project)
end
end
......@@ -30,6 +30,10 @@ module StubGitlabCalls
allow_any_instance_of(Project).to receive(:builds_enabled?).and_return(false)
end
def stub_packages_config(settings)
allow(Gitlab.config.packages).to receive_messages(settings)
end
def stub_container_registry_config(registry_settings)
allow(Gitlab.config.registry).to receive_messages(registry_settings)
allow(Auth::ContainerRegistryAuthenticationService)
......
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