Commit 1189f70b authored by dgt's avatar dgt Committed by azul

fix extension tests and execute them via CI

in rails 5 test can be executed via rails test (which also works for directories)
removed testing.rake which added the pages tests, because Rake::TestTask does not exist anymore
we loose the ability to call all unit | functional | integration tests (including extensions)
parent 7a912d4c
......@@ -35,7 +35,8 @@ test:
bundle exec rake db:test:prepare
RAILS_ENV=test bundle exec rake db:fixtures:load
RAILS_ENV=test bundle exec rake ts:index ts:start
bundle exec rake
bundle exec rails test
bundle exec rails test extensions/pages
bundle exec rake cg:cleanup:all # test cleanup tasks
artifacts:
when: on_failure
......@@ -61,7 +62,8 @@ test_stretch:
bundle exec rake db:test:prepare
RAILS_ENV=test bundle exec rake db:fixtures:load
RAILS_ENV=test bundle exec rake ts:index ts:start
bundle exec rake
bundle exec rails test
bundle exec rails test extensions/pages
bundle exec rake cg:cleanup:all # test cleanup tasks
artifacts:
when: on_failure
......
......@@ -91,7 +91,7 @@ ul.list_as_cols {
//
ul.clickable {
@extend ul.shaded;
@extend ul, .shaded;
@extend .round;
@extend .list-unstyled;
margin-bottom: 20px;
......@@ -141,4 +141,4 @@ ul.shaded {
.list-group-item:nth-child(odd) {
background-color: $color_lighter;
}
}
\ No newline at end of file
}
......@@ -32,7 +32,7 @@ class CreateAssetPageController < Page::CreateController
end
def ensure_asset
if params[:asset].blank?
if params[:asset].blank? || params[:asset][:uploaded_data].blank?
warning :select_file_to_upload.t
new
end
......
......@@ -23,7 +23,7 @@ class CreateAssetPageControllerTest < ActionController::TestCase
post 'create', page_id: 'me',
page: { title: 'test' },
asset: { uploaded_data: nil }
assert_equal :error, flash[:messages].first[:type],
assert_equal :warning, flash[:messages].first[:type],
"shouldn't be able to create an asset page with no asset"
end
end
......
......@@ -60,8 +60,8 @@ class TasksController < Page::BaseController
def task_params
params.require(:task)
.reverse_merge(user_ids: [])
.permit(:name, :description, user_ids: []).to_h
.reverse_merge(user_ids: [])
end
def sort_params
......
......@@ -19,7 +19,7 @@ class TaskListPage < Page
# For relations we first build the task_ids.
# Using the relation in the where clause will result in a subselect
# with a join that makes for a very slow query.
task_ids = tasks.respond_to?(:pluck) ? tasks.pluck(:id) : tasks
task_ids = tasks.kind_of?(Array) ? tasks : tasks.pluck(:id)
includes(:tasks).where(tasks: { id: task_ids })
end
end
#
# Include Page tests in default test task
#
namespace :test do
desc 'Test everything: crabgrass, pages and mods.'
Rake::TestTask.new(:everything) do |t|
t.libs << 'test'
t.test_files = FileList['test/**/*_test.rb'] +
FileList['extensions/pages/**/test/**/*_test.rb']
t.verbose = true
end
end
#
# Testing pages
#
namespace :test do
namespace :pages do
desc 'Run the plugin tests in extensions/pages/**/test (or specify with PAGE=name)'
task all: %i[units functionals integration]
desc 'Run all pages unit tests'
Rake::TestTask.new(units: :setup_plugin_fixtures) do |t|
t.libs << 'test'
t.pattern = "extensions/pages/#{ENV['PAGE'] || '**'}/test/unit/**/*_test.rb"
t.verbose = true
end
desc 'Run all pages functional tests'
Rake::TestTask.new(functionals: :setup_plugin_fixtures) do |t|
t.libs << 'test'
t.pattern = "extensions/pages/#{ENV['PAGE'] || '**'}/test/functional/**/*_test.rb"
t.verbose = true
end
desc 'Integration test engines for pages'
Rake::TestTask.new(integration: :setup_plugin_fixtures) do |t|
t.libs << 'test'
t.pattern = "extensions/pages/#{ENV['PAGE'] || '**'}/test/integration/**/*_test.rb"
t.verbose = true
end
desc 'Mirrors plugin fixtures into a single location to help plugin tests'
task setup_plugin_fixtures: :environment do
# Engines::Testing.setup_plugin_fixtures
end
end
end
......@@ -81,8 +81,6 @@ class DiscussionTest < ActiveSupport::TestCase
end
assert_equal post, discussion.last_post
assert post.updated_at - discussion.replied_at < 1
# FIXME: why do we need this?
# assert post.updated_at > discussion.replied_at
assert_equal post.user, discussion.replied_by
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