Basic tests added
This commit is contained in:
parent
6239fb4dcb
commit
5498e9b9a4
8 changed files with 137 additions and 30 deletions
|
|
@ -1,9 +1,21 @@
|
|||
require "test_helper"
|
||||
|
||||
class AdminControllerTest < ActionController::TestCase
|
||||
test "should get status" do
|
||||
test "user must login" do
|
||||
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
|
||||
|
|
|
|||
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:
|
||||
name: firefox
|
||||
description: A web browser
|
||||
|
|
@ -32,3 +8,43 @@ firefox:
|
|||
homepage: http://www.mozilla.org/
|
||||
version: 10.01alpha-7
|
||||
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 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
|
||||
# require "minitest/pride"
|
||||
require "minitest/pride"
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
||||
|
|
@ -22,4 +24,19 @@ end
|
|||
|
||||
class ActionController::TestCase
|
||||
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