Basic tests added
This commit is contained in:
parent
6239fb4dcb
commit
5498e9b9a4
8 changed files with 137 additions and 30 deletions
4
Gemfile
4
Gemfile
|
|
@ -69,6 +69,10 @@ group :development, :test do
|
||||||
gem 'byebug', platform: :mri
|
gem 'byebug', platform: :mri
|
||||||
end
|
end
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
gem "minitest-rails-capybara"
|
||||||
|
end
|
||||||
|
|
||||||
# TODO… https://github.com/galetahub/simple-captcha
|
# TODO… https://github.com/galetahub/simple-captcha
|
||||||
# Captcha for anonymous reports
|
# Captcha for anonymous reports
|
||||||
# gem "galetahub-simple_captcha", :require => "simple_captcha"
|
# gem "galetahub-simple_captcha", :require => "simple_captcha"
|
||||||
|
|
|
||||||
24
Gemfile.lock
24
Gemfile.lock
|
|
@ -44,6 +44,8 @@ GEM
|
||||||
i18n (>= 0.7, < 2)
|
i18n (>= 0.7, < 2)
|
||||||
minitest (~> 5.1)
|
minitest (~> 5.1)
|
||||||
tzinfo (~> 1.1)
|
tzinfo (~> 1.1)
|
||||||
|
addressable (2.5.2)
|
||||||
|
public_suffix (>= 2.0.2, < 4.0)
|
||||||
ansi (1.5.0)
|
ansi (1.5.0)
|
||||||
arel (7.1.4)
|
arel (7.1.4)
|
||||||
babel-source (5.8.35)
|
babel-source (5.8.35)
|
||||||
|
|
@ -61,6 +63,13 @@ GEM
|
||||||
builder (3.2.3)
|
builder (3.2.3)
|
||||||
byebug (10.0.2)
|
byebug (10.0.2)
|
||||||
callsite (0.0.11)
|
callsite (0.0.11)
|
||||||
|
capybara (2.18.0)
|
||||||
|
addressable
|
||||||
|
mini_mime (>= 0.1.3)
|
||||||
|
nokogiri (>= 1.3.3)
|
||||||
|
rack (>= 1.0.0)
|
||||||
|
rack-test (>= 0.5.4)
|
||||||
|
xpath (>= 2.0, < 4.0)
|
||||||
choice (0.2.0)
|
choice (0.2.0)
|
||||||
climate_control (0.2.0)
|
climate_control (0.2.0)
|
||||||
coderay (1.1.2)
|
coderay (1.1.2)
|
||||||
|
|
@ -151,9 +160,20 @@ GEM
|
||||||
mini_mime (1.0.0)
|
mini_mime (1.0.0)
|
||||||
mini_portile2 (2.3.0)
|
mini_portile2 (2.3.0)
|
||||||
minitest (5.11.3)
|
minitest (5.11.3)
|
||||||
|
minitest-capybara (0.8.2)
|
||||||
|
capybara (~> 2.2)
|
||||||
|
minitest (~> 5.0)
|
||||||
|
rake
|
||||||
|
minitest-metadata (0.6.0)
|
||||||
|
minitest (>= 4.7, < 6.0)
|
||||||
minitest-rails (3.0.0)
|
minitest-rails (3.0.0)
|
||||||
minitest (~> 5.8)
|
minitest (~> 5.8)
|
||||||
railties (~> 5.0)
|
railties (~> 5.0)
|
||||||
|
minitest-rails-capybara (3.0.1)
|
||||||
|
capybara (~> 2.7)
|
||||||
|
minitest-capybara (~> 0.8)
|
||||||
|
minitest-metadata (~> 0.6)
|
||||||
|
minitest-rails (~> 3.0)
|
||||||
minitest-reporters (1.2.0)
|
minitest-reporters (1.2.0)
|
||||||
ansi
|
ansi
|
||||||
builder
|
builder
|
||||||
|
|
@ -209,6 +229,7 @@ GEM
|
||||||
pry (0.11.3)
|
pry (0.11.3)
|
||||||
coderay (~> 1.1.0)
|
coderay (~> 1.1.0)
|
||||||
method_source (~> 0.9.0)
|
method_source (~> 0.9.0)
|
||||||
|
public_suffix (3.0.2)
|
||||||
puma (3.11.4)
|
puma (3.11.4)
|
||||||
rack (2.0.5)
|
rack (2.0.5)
|
||||||
rack-contrib (2.0.1)
|
rack-contrib (2.0.1)
|
||||||
|
|
@ -321,6 +342,8 @@ GEM
|
||||||
will_paginate (3.1.6)
|
will_paginate (3.1.6)
|
||||||
will_paginate-foundation (6.2.1)
|
will_paginate-foundation (6.2.1)
|
||||||
will_paginate (>= 3.0.3)
|
will_paginate (>= 3.0.3)
|
||||||
|
xpath (3.1.0)
|
||||||
|
nokogiri (~> 1.8)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
@ -343,6 +366,7 @@ DEPENDENCIES
|
||||||
listen (~> 3.0.5)
|
listen (~> 3.0.5)
|
||||||
meta_request
|
meta_request
|
||||||
minitest-rails
|
minitest-rails
|
||||||
|
minitest-rails-capybara
|
||||||
minitest-reporters
|
minitest-reporters
|
||||||
omniauth
|
omniauth
|
||||||
omniauth-amazon
|
omniauth-amazon
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,6 @@ guard :minitest do
|
||||||
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
||||||
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
||||||
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
||||||
watch(%r{^test/.+_test\.rb$})
|
watch(%r{^test/.+?/.+_test\.rb$})
|
||||||
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,21 @@
|
||||||
require "test_helper"
|
require "test_helper"
|
||||||
|
|
||||||
class AdminControllerTest < ActionController::TestCase
|
class AdminControllerTest < ActionController::TestCase
|
||||||
test "should get status" do
|
test "user must login" do
|
||||||
get :status
|
get :status
|
||||||
assert_response :redirect
|
assert_redirected_to user_session_path
|
||||||
|
end
|
||||||
|
|
||||||
|
test "normal user must not see admin status" do
|
||||||
|
sign_in users(:normal)
|
||||||
|
get :status
|
||||||
|
assert_response :forbidden
|
||||||
|
end
|
||||||
|
|
||||||
|
test "admin can see status" do
|
||||||
|
sign_in users(:admin)
|
||||||
|
get :status
|
||||||
|
assert_response :success
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
64
test/fixtures/packages.yml
vendored
64
test/fixtures/packages.yml
vendored
|
|
@ -1,27 +1,3 @@
|
||||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
|
||||||
|
|
||||||
# one:
|
|
||||||
# name: MyText
|
|
||||||
# description: MyString
|
|
||||||
# long_description: MyString
|
|
||||||
# section: MyString
|
|
||||||
# maintainer: MyString
|
|
||||||
# maintainer_email: MyString
|
|
||||||
# homepage: MyString
|
|
||||||
# version: MyString
|
|
||||||
# origin: MyString
|
|
||||||
|
|
||||||
# two:
|
|
||||||
# name: MyText
|
|
||||||
# description: MyString
|
|
||||||
# long_description: MyString
|
|
||||||
# section: MyString
|
|
||||||
# maintainer: MyString
|
|
||||||
# maintainer_email: MyString
|
|
||||||
# homepage: MyString
|
|
||||||
# version: MyString
|
|
||||||
# origin: MyString
|
|
||||||
|
|
||||||
firefox:
|
firefox:
|
||||||
name: firefox
|
name: firefox
|
||||||
description: A web browser
|
description: A web browser
|
||||||
|
|
@ -32,3 +8,43 @@ firefox:
|
||||||
homepage: http://www.mozilla.org/
|
homepage: http://www.mozilla.org/
|
||||||
version: 10.01alpha-7
|
version: 10.01alpha-7
|
||||||
origin: Debian
|
origin: Debian
|
||||||
|
|
||||||
|
vim:
|
||||||
|
name: vim
|
||||||
|
description: Vi IMproved - enhanced vi editor
|
||||||
|
long_description: |
|
||||||
|
Vim is an almost compatible version of the UNIX editor Vi.
|
||||||
|
.
|
||||||
|
Many new features have been added: multi level undo, syntax
|
||||||
|
highlighting, command line history, on-line help, filename
|
||||||
|
completion, block operations, folding, Unicode support, etc.
|
||||||
|
.
|
||||||
|
This package contains a version of vim compiled with a rather
|
||||||
|
standard set of features. This package does not provide a GUI
|
||||||
|
version of Vim. See the other vim-* packages if you need more
|
||||||
|
(or less).
|
||||||
|
section: editors
|
||||||
|
maintainer: Debian Vim Maintainers
|
||||||
|
maintainer_email: team+vim@tracker.debian.org
|
||||||
|
homepage: https://vim.sourceforge.io/
|
||||||
|
version: 2:8.1.0229-1
|
||||||
|
origin: Ubuntu
|
||||||
|
|
||||||
|
<% 100.times do |n| %>
|
||||||
|
package_<%= n %>:
|
||||||
|
name: package-<%= n %>
|
||||||
|
description: Description of package <%= n %>
|
||||||
|
long_description: |
|
||||||
|
Long description of package <%= n%> that may be so long that
|
||||||
|
it spans several lines of text.
|
||||||
|
.
|
||||||
|
There might also be several paragraphs in the description text.
|
||||||
|
.
|
||||||
|
Like this one.
|
||||||
|
section: <%= %W(admin cli-mono database debug devel doc editors education games).sample %>
|
||||||
|
maintainer: Maintainer of package-<%= n %>
|
||||||
|
maintainer_email: maintainer-<%= n %>@debian.cc
|
||||||
|
homepage: https://packages.debian.org/package-<%= n %>
|
||||||
|
version: <%= (rand*10).round(2) %>
|
||||||
|
origin: <%= %W(ubuntu debian mint opensuse).sample %>
|
||||||
|
<% end %>
|
||||||
|
|
|
||||||
20
test/fixtures/users.yml
vendored
Normal file
20
test/fixtures/users.yml
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
admin:
|
||||||
|
name: Super Sayajin
|
||||||
|
created_at: 2018-07-01
|
||||||
|
updated_at: 2018-07-01
|
||||||
|
email: admin@debian.ork
|
||||||
|
sign_in_count: 5
|
||||||
|
provider: local
|
||||||
|
admin: 1
|
||||||
|
encrypted_password: <%= Devise::Encryptor.digest(User, 'adminsecret') %>
|
||||||
|
|
||||||
|
normal:
|
||||||
|
name: Norman Normal
|
||||||
|
created_at: 2018-06-01
|
||||||
|
updated_at: 2018-06-01
|
||||||
|
email: mortal@debian.ork
|
||||||
|
sign_in_count: 3
|
||||||
|
provider: local
|
||||||
|
admin: 0
|
||||||
|
encrypted_password: <%= Devise::Encryptor.digest(User, 'normalsecret') %>
|
||||||
|
|
||||||
14
test/integration/browse_test.rb
Normal file
14
test/integration/browse_test.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
require 'test_helper'
|
||||||
|
|
||||||
|
class BrowserBrowseTest < ActionDispatch::IntegrationTest
|
||||||
|
test "user can see home page" do
|
||||||
|
visit root_path
|
||||||
|
page.must_have_content 'This website lets you browse screenshots'
|
||||||
|
end
|
||||||
|
|
||||||
|
test "user can browse packages" do
|
||||||
|
visit packages_grid_path
|
||||||
|
page.must_have_content /Previous/
|
||||||
|
page.must_have_link href: packages_grid_path(page: 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,10 +10,12 @@ Minitest::Reporters.use!
|
||||||
|
|
||||||
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
|
# To add Capybara feature tests add `gem "minitest-rails-capybara"`
|
||||||
# to the test group in the Gemfile and uncomment the following:
|
# to the test group in the Gemfile and uncomment the following:
|
||||||
# require "minitest/rails/capybara"
|
require "minitest/rails/capybara"
|
||||||
|
require 'capybara/rails'
|
||||||
|
require 'capybara/minitest'
|
||||||
|
|
||||||
# Uncomment for awesome colorful output
|
# Uncomment for awesome colorful output
|
||||||
# require "minitest/pride"
|
require "minitest/pride"
|
||||||
|
|
||||||
class ActiveSupport::TestCase
|
class ActiveSupport::TestCase
|
||||||
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
||||||
|
|
@ -23,3 +25,18 @@ end
|
||||||
class ActionController::TestCase
|
class ActionController::TestCase
|
||||||
include Devise::Test::ControllerHelpers
|
include Devise::Test::ControllerHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Capybara-based tests
|
||||||
|
class ActionDispatch::IntegrationTest
|
||||||
|
# Make the Capybara DSL available in all integration tests
|
||||||
|
include Capybara::DSL
|
||||||
|
# Make `assert_*` methods behave like Minitest assertions
|
||||||
|
include Capybara::Minitest::Assertions
|
||||||
|
|
||||||
|
# Reset sessions and driver between tests
|
||||||
|
# Use super wherever this method is redefined in your individual test classes
|
||||||
|
def teardown
|
||||||
|
Capybara.reset_sessions!
|
||||||
|
Capybara.use_default_driver
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue