Commit a32469f6 authored by dgt's avatar dgt Committed by azul

Upgrade to Rails 5.1

and fixed wiki versioning test

Rails 5.1 last steps

crabgrass_media from rubygems
remove controller test for task sorting - not possible to test xhr request without route in new parameter syntax
remove new framework defaults initializer file

Final step of upgrade to rails 5.1

we only test on stretch, because we need ruby >= 2.2.2
update dependencies by running bundle update
and fix gallery_image_controller_test
parent 42166373
......@@ -22,30 +22,6 @@ bundle_audit:
bundle-audit update
bundle-audit check
test:
stage: test
services:
- mysql:5.5
script: |
bundle exec rake create_a_secret
cp config/database.yml.example config/database.yml
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake cg:test:update_fixtures
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 rails test
bundle exec rails test extensions/pages
bundle exec rake cg:cleanup:all # test cleanup tasks
artifacts:
when: on_failure
paths:
- log/test.log
- tmp/*.log
- tmp/*.html
- tmp/*.png
test_stretch:
image: 0xacab.org:4567/riseuplabs/docker/crabgrass:stretch_amd64
stage: test
......
......@@ -11,8 +11,7 @@ end
##
# Rails is the framework we use.
#gem 'rails', '~> 5.1.6'
gem 'rails', '~> 5.0.7'
gem 'rails', '~> 5.1.6'
# Security updates
# https://github.com/sparklemotion/nokogiri/issues/1785
......@@ -144,8 +143,7 @@ gem 'greencloth', require: 'greencloth',
# media upload post processing has it's own repo
# version is rather strict for now as api may still change.
gem 'crabgrass_media', '~> 0.3.0', require: 'media',
path: 'vendor/gems/crabgrass-media'
gem 'crabgrass_media', '~> 0.3.0', require: 'media'
##
## not required, but a really good idea
......
......@@ -6,13 +6,6 @@ GIT
prototype-rails (4.1.3)
rails (>= 4.2)
PATH
remote: vendor/gems/crabgrass-media
specs:
crabgrass_media (0.3.0)
activesupport (~> 5.0)
mime-types (~> 3.1)
PATH
remote: vendor/gems/riseuplabs-greencloth-0.1
specs:
......@@ -24,89 +17,94 @@ GEM
specs:
RedCloth (4.3.2)
aasm (3.4.0)
actioncable (5.0.7.2)
actionpack (= 5.0.7.2)
nio4r (>= 1.2, < 3.0)
actioncable (5.1.7)
actionpack (= 5.1.7)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
actionmailer (5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.0.7.2)
actionview (= 5.0.7.2)
activesupport (= 5.0.7.2)
actionpack (5.1.7)
actionview (= 5.1.7)
activesupport (= 5.1.7)
rack (~> 2.0)
rack-test (~> 0.6.3)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionpack-page_caching (1.1.0)
actionpack-page_caching (1.1.1)
actionpack (>= 4.0.0, < 6)
actionview (5.0.7.2)
activesupport (= 5.0.7.2)
actionview (5.1.7)
activesupport (= 5.1.7)
builder (~> 3.1)
erubis (~> 2.7.0)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.0.7.2)
activesupport (= 5.0.7.2)
activejob (5.1.7)
activesupport (= 5.1.7)
globalid (>= 0.3.6)
activemodel (5.0.7.2)
activesupport (= 5.0.7.2)
activerecord (5.0.7.2)
activemodel (= 5.0.7.2)
activesupport (= 5.0.7.2)
arel (~> 7.0)
activesupport (5.0.7.2)
activemodel (5.1.7)
activesupport (= 5.1.7)
activerecord (5.1.7)
activemodel (= 5.1.7)
activesupport (= 5.1.7)
arel (~> 8.0)
activesupport (5.1.7)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
acts-as-taggable-on (6.0.0)
activerecord (~> 5.0)
acts_as_list (0.9.1)
acts_as_list (0.9.19)
activerecord (>= 3.0)
addressable (2.5.0)
public_suffix (~> 2.0, >= 2.0.2)
arel (7.1.4)
bcrypt (3.1.11)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
arel (8.0.0)
bcrypt (3.1.12)
builder (3.2.3)
bundler-audit (0.6.1)
bundler (>= 1.2.0, < 3)
thor (~> 0.18)
byebug (9.0.6)
capybara (2.12.0)
byebug (11.0.1)
capybara (3.15.1)
addressable
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.2)
xpath (~> 3.2)
chronic (0.10.2)
cliver (0.3.2)
concurrent-ruby (1.1.5)
crabgrass_media (0.3.0)
activesupport (~> 5.0)
mime-types (~> 3.1)
crass (1.0.4)
daemons (1.2.4)
delayed_job (4.1.2)
activesupport (>= 3.0, < 5.1)
delayed_job_active_record (4.1.1)
activerecord (>= 3.0, < 5.1)
daemons (1.3.1)
delayed_job (4.1.5)
activesupport (>= 3.0, < 5.3)
delayed_job_active_record (4.1.3)
activerecord (>= 3.0, < 5.3)
delayed_job (>= 3.0, < 5)
docile (1.1.5)
docile (1.3.1)
erubi (1.8.0)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (4.8.2)
activesupport (>= 3.0.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
railties (>= 3.0.0)
factory_bot (5.0.2)
activesupport (>= 4.2.0)
factory_bot_rails (5.0.2)
factory_bot (~> 5.0.2)
railties (>= 4.2.0)
faker (1.0.1)
i18n (~> 0.4)
ffi (1.9.25)
ffi (1.10.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
gpgme (2.0.16)
gpgme (2.0.18)
mini_portile2 (~> 2.3)
haml (5.0.4)
temple (>= 0.8.0)
......@@ -122,14 +120,14 @@ GEM
haml (>= 4.0, < 6)
nokogiri (>= 1.6.0)
ruby_parser (~> 3.5)
http_accept_language (2.1.0)
http_accept_language (2.1.1)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
innertube (1.1.0)
joiner (0.3.4)
activerecord (>= 4.1.0)
json (1.8.6)
libv8 (3.16.14.17)
libv8 (3.16.14.19)
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
......@@ -140,9 +138,9 @@ GEM
mail (~> 2.5, >= 2.5.3)
method_source (0.9.2)
middleware (0.1.0)
mime-types (3.1)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mime-types-data (3.2019.0331)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.10.3)
......@@ -152,27 +150,27 @@ GEM
mini_portile2 (~> 2.3.0)
phantomjs-binaries (2.1.1.1)
sys-uname (= 0.9.0)
poltergeist (1.13.0)
capybara (~> 2.1)
poltergeist (1.18.1)
capybara (>= 2.1, < 4)
cliver (~> 0.3.1)
websocket-driver (>= 0.2.0)
public_suffix (2.0.5)
public_suffix (3.0.3)
pundit (1.1.0)
activesupport (>= 3.0.0)
rack (2.0.7)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.7.2)
actioncable (= 5.0.7.2)
actionmailer (= 5.0.7.2)
actionpack (= 5.0.7.2)
actionview (= 5.0.7.2)
activejob (= 5.0.7.2)
activemodel (= 5.0.7.2)
activerecord (= 5.0.7.2)
activesupport (= 5.0.7.2)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.7)
actioncable (= 5.1.7)
actionmailer (= 5.1.7)
actionpack (= 5.1.7)
actionview (= 5.1.7)
activejob (= 5.1.7)
activemodel (= 5.1.7)
activerecord (= 5.1.7)
activesupport (= 5.1.7)
bundler (>= 1.3.0)
railties (= 5.0.7.2)
railties (= 5.1.7)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.4)
actionpack (>= 5.0.1.x)
......@@ -183,34 +181,41 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.0.7.2)
actionpack (= 5.0.7.2)
activesupport (= 5.0.7.2)
railties (5.1.7)
actionpack (= 5.1.7)
activesupport (= 5.1.7)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.5.0)
rdoc (4.3.0)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
ffi (~> 1.0)
rdoc (6.1.1)
record_tag_helper (1.0.0)
actionview (~> 5.x)
ref (2.0.0)
riddle (2.2.2)
regexp_parser (1.4.0)
riddle (2.3.2)
ruby_parser (3.13.1)
sexp_processor (~> 4.9)
rubyzip (1.2.2)
sass (3.4.23)
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sdoc (1.0.0)
rdoc (>= 5.0)
secure_headers (4.0.2)
useragent (>= 0.15.0)
sexp_processor (4.12.0)
simplecov (0.14.1)
docile (~> 1.1.0)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.1)
spring (2.0.1)
simplecov-html (0.10.2)
spring (2.0.2)
activesupport (>= 4.2)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
......@@ -219,7 +224,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
sqlite3 (1.3.13)
sqlite3 (1.4.0)
sys-uname (0.9.0)
ffi (>= 1.0.0)
temple (0.8.1)
......@@ -236,26 +241,27 @@ GEM
thor (0.20.3)
thread_safe (0.3.6)
tilt (2.0.9)
ts-delayed-delta (2.0.2)
ts-delayed-delta (2.1.0)
activerecord (>= 2.0)
delayed_job
thinking-sphinx (>= 1.5.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (3.0.4)
uglifier (4.1.20)
execjs (>= 0.3.0, < 3)
useragent (0.16.9)
useragent (0.16.10)
utf8-cleaner (0.2.5)
activesupport
validates_email_format_of (1.6.3)
i18n
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whenever (0.9.7)
websocket-extensions (0.1.3)
whenever (0.11.0)
chronic (>= 0.6.3)
will_paginate (3.1.5)
xpath (2.0.0)
nokogiri (~> 1.3)
will_paginate (3.1.7)
xpath (3.2.0)
nokogiri (~> 1.8)
zip-zip (0.3)
rubyzip (>= 1.0.0)
......@@ -272,7 +278,7 @@ DEPENDENCIES
bundler-audit
byebug
capybara
crabgrass_media (~> 0.3.0)!
crabgrass_media (~> 0.3.0)
daemons
delayed_job_active_record (~> 4.0)
factory_bot_rails
......@@ -293,7 +299,7 @@ DEPENDENCIES
poltergeist (~> 1.5)
prototype-rails!
pundit (~> 1.1)
rails (~> 5.0.7)
rails (~> 5.1.6)
rails-controller-testing
rake (~> 10.0)
record_tag_helper (~> 1.0)
......
......@@ -39,8 +39,6 @@ class Page::CreateController < ApplicationController
redirect_to page_url(@page)
end
protected
# if the page controller is called by our custom DispatchController,
# objects which have already been loaded will be passed to the tool
# via this initialize method.
......@@ -51,6 +49,8 @@ class Page::CreateController < ApplicationController
@page = seed[:page] # the page object, if already fetched
end
protected
#
# before filters
#
......
......@@ -80,7 +80,7 @@ class Asset < ApplicationRecord
# This is included here because Asset may take new attachment file data, but
# Asset::Version and Thumbnail don't need to.
include Asset::Upload
validates_presence_of :filename, unless: 'new_record?'
validates_presence_of :filename, unless: :new_record?
##
## ACCESS
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ class GalleryImageControllerTest < ActionController::TestCase
def test_show_not_found
login_as :blue
assert @asset.id, 'image should not be nil'
xhr :get, :show, id: 111, page_id: @gallery.id
get :show, params: { id: 111, page_id: @gallery.id }, xhr: true
assert_not assigns(:showing)
assert_response 404
end
......
......@@ -9,19 +9,6 @@ class TasksControllerTest < ActionController::TestCase
login_as @user
end
def test_sort
assert_equal 1, Task.find(1).position
assert_equal 2, Task.find(2).position
assert_equal 3, Task.find(3).position
post :sort, params: { page_id: @page.id, sort_list_pending: ["3", "2", "1"] }, xhr: true
assert_response :success
assert_equal 3, Task.find(1).position
assert_equal 2, Task.find(2).position
assert_equal 1, Task.find(3).position
end
def test_create_task
assert_difference '@page.tasks.count' do
post :create, params: { page_id: @page.id, task: { name: "new task", user_ids: ["5"], description: "new task description" } }, xhr: true
......
......@@ -5,11 +5,12 @@ class Wiki::VersionsControllerTest < ActionController::TestCase
@user = FactoryBot.create(:user)
@group = FactoryBot.create(:group)
@group.add_user!(@user)
@wiki = @group.profiles.public.create_wiki body: 'test'
@wiki.body = @original_body = 'original wiki body'
@wiki = @group.profiles.public.create_wiki body: 'original wiki body'
@wiki.updated_at = 1.day.ago # force an older timestamp, so that
# changing the wiki will create a new version.
@wiki.save
@wiki.body = 'updated wiki body'
@wiki.save
@version = @wiki.versions.last
login_as @user
end
......
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/db/*.sqlite3-journal
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache
image: 0xacab.org:4567/riseuplabs/docker/crabgrass:stretch_amd64
cache:
paths:
- vendor/ruby
before_script:
- ruby -v
- which ruby
- bundle --version
- libreoffice --version
- bundle install -j $(nproc) --path vendor "${FLAGS[@]}"
test_stretch:
stage: test
script: |
bundle exec rake
artifacts:
when: on_failure
paths:
- log/*.log
bundle_audit:
stage: test
allow_failure: true
script: |
sudo gem install bundler-audit
bundle-audit update
bundle-audit check
language: ruby
sudo: :required
rvm:
- 1.9.3
- 2.1.5
matrix:
fast_finish: true
addons:
apt:
packages:
- graphicsmagick
- inkscape
before_install:
- sudo apt-get install libreoffice-writer
- bundle --version
- libreoffice --version
notifications:
email: false
after_script:
- "cat log/*.log" # printing all logs to investigate issues on CI
<a name="0.2.0"></a>
### 0.2.0 (2017-02-23)
#### Upgrade
* require rails 4.2
#### Bug Fixes
* fix all warnings from gem build ([9add68a](/../commit/9add68a))
* warnings during test run ([245564f](/../commit/245564f))
* duplicate keys in mime type hash ([131cb9b](/../commit/131cb9b))
<a name="0.1.1"></a>
### 0.1.1 (2017-02-24)
#### Bug Fixes
* prevent raising ENOENT on failure ([dfb0baf](/../commit/dfb0baf))
<a name="0.1.0"></a>
### 0.1.0 (2017-02-24)
#### Features
* use new class names for crabgrass 0.7 ([909295f](/../commit/909295f))
source 'https://rubygems.org'
# Declare your gem's dependencies in media.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
PATH
remote: .
specs:
crabgrass_media (0.3.0)
activesupport (~> 5.0)
mime-types (~> 3.1)
GEM
remote: https://rubygems.org/
specs:
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
concurrent-ruby (1.0.5)
conventional-changelog (1.2.2)
i18n (0.9.1)
concurrent-ruby (~> 1.0)
mime-types (3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
minitest (5.11.1)
rake (12.0.0)
thread_safe (0.3.6)
tzinfo (1.2.4)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
conventional-changelog (~> 1.2)
crabgrass_media!
minitest (~> 5.10)
rake (~> 12.0)
BUNDLED WITH
1.16.0
Crabgrass::Media is the Media engine of Crabgrass.
Crabgrass is a web application designed for activist groups to be better able to collaborate online. Mostly, it is a glorified wiki with fine-grain control over access rights.
Crabgrass::Media is a rails engine to do media transformations.
You can add new media transformations by subclassing Transmogrifier.
Example usage:
```ruby
transmog = Media.transmogrifier(:input_file => 'myfile.odt', :output_file => 'myfile.jpg')
status = transmog.run do |progress|
puts progress
end
```
Tests require the 'file' utility to be installed to determine the file
type of the created files.
Crabgrass and Crabgrass::Media are based on Ruby on Rails and MySQL.
They are released under the AGPL license, version 3.
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rdoc/task'
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'Media'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
task default: :test
unless defined?(Media::TMP_PATH)
if defined?(Rails)
Media::TMP_PATH = File.join(Rails.root, 'tmp', 'media')
else
Media::TMP_PATH = File.join('', 'tmp', 'media')
end
end
FileUtils.mkdir_p(Media::TempFile.tempfile_path) unless File.exist?(Media::TempFile.tempfile_path)
$:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "media/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "crabgrass_media"
s.version = Media::VERSION
s.authors = ["Azul"]
s.email = ["azul@riseup.net"]
s.homepage = "https://github.com/riseuplabs/crabgrass-media"
s.summary = "Media processing for the Crabgrass social wiki"
s.description = <<-EOD
Crabgrass::Media is the Media engine of Crabgrass.
Crabgrass is a web application designed for activist groups to be better able to collaborate online. Mostly, it is a glorified wiki with fine-grain control over access rights.
Crabgrass::Media is a rails engine to do media transformations.
EOD
s.license = "AGPL-3.0"
s.files = Dir["{config,lib}/**/*", "Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]
s.add_dependency 'activesupport', '~> 5.0'
s.add_dependency 'mime-types', '~> 3.1'
s.add_development_dependency 'rake', '~> 12.0'
s.add_development_dependency 'minitest', ' ~> 5.10'
s.add_development_dependency 'conventional-changelog', '~> 1.2'
end
require 'media/mime_type'
require 'media/temp_file'
require 'media/transmogrifier'
require 'media/transmogrifiers/graphicsmagick'
require 'media/transmogrifiers/inkscape'
require 'media/transmogrifiers/libremagick'
require 'media/transmogrifiers/libreoffice'
module Media
#
# creates a new instance of transmogrifier suitable for turning
# input into output.
#
def self.transmogrifier(options)
if options[:input_type]
input_type = Media::MimeType.simple options[:input_type]
elsif options[:input_file]
input_type = Media::MimeType.mime_type_from_extension options[:input_file]
else
raise ArgumentError.new
end
if options[:output_type]
output_type = Media::MimeType.simple options[:output_type]
elsif options[:output_file]
output_type = Media::MimeType.mime_type_from_extension options[:output_file]
else
raise ArgumentError.new
end