Commit Graph

9483 Commits

Author SHA1 Message Date
evazion
025e09ff7f tests: upload test coverage reports to code climate.
Downgrade simplecov to 0.17 because 0.18 is incompatible with code
climate. Ref: github.com codeclimate/test-reporter/issues/413
2020-06-11 15:35:15 -05:00
evazion
8181ee6a1d Update rubocop config. 2020-06-11 14:08:23 -05:00
evazion
889c4ce4d9 Add Code Climate integration. 2020-06-11 13:31:17 -05:00
evazion
be4646aa6f tests: fix username conflicts in parallel tests.
Parallel tests sometimes failed because the username generator sometimes
generated duplicate usernames.
2020-06-11 02:43:19 -05:00
evazion
e14a577ed9 tests: clean up test_helper.rb initialization. 2020-06-11 02:41:44 -05:00
evazion
8e50f1d1a0 tests: remove unused test images in tmp/. 2020-06-11 02:41:17 -05:00
evazion
27c5361b96 tests: add minimum test coverage requirements. 2020-06-11 02:40:02 -05:00
evazion
a829fbfb8d tests: fix test coverage reporting for parallel testing.
* Fix simplecov clobbering test coverage reports when using parallel tests.
* Generate coverage reports by default (remove $SIMPLECOV flag).
* Store coverage reports in tmp/coverage/ instead of coverage/.
* Enable branch coverage.

ref: github.com /colszowka/simplecov/issues/718#issuecomment-538201587
2020-06-11 02:16:20 -05:00
evazion
99a9149fc4 tests: eliminate as_user helper. 2020-06-11 01:02:01 -05:00
evazion
2d05004bef tests: don't cache pixiv sessions. 2020-06-11 00:47:12 -05:00
evazion
7ba786010d tests: store test uploads in temp dir.
Fixes parallel tests failing because uploads for different tests were
stored in the same directory and uploads got clobbered when cleaning up
this directory.
2020-06-10 22:54:33 -05:00
evazion
04c8c25976 tests: initialize pawoo credentials in github tests. 2020-06-10 22:49:28 -05:00
evazion
88dfc463a1 db/seeds: fix deprecation warning in find_or_create_by!.
`User.find_or_create_by!` calls `User.name_matches` during username
validation, which triggers a deprecation warning for some reason:

    DEPRECATION WARNING: Class level methods will no longer inherit scoping
    from `create!` in Rails 6.1. To continue using the scoped relation,
    pass it into the block directly. To instead access the full set of
    models, as Rails 6.1 will, use `User.default_scoped`.
2020-06-10 22:33:36 -05:00
evazion
5919fa0ca1 tests: enable parallel tests. 2020-06-10 22:26:47 -05:00
evazion
60e96f0e01 tests: fix post url generation test. 2020-06-10 20:22:21 -05:00
evazion
2ede41c4dc tests: fix twitter test broken by deleted tweet. 2020-06-10 20:22:16 -05:00
evazion
ab1931a920 tests: fix artstation download tests.
Fix ArtStation download tests that were broken when 266e4054 added the
ability to download /4k/ files.
2020-06-10 19:45:56 -05:00
evazion
d6b266514b tests: disable known broken pixiv fanbox tests. 2020-06-10 18:21:44 -05:00
evazion
45b3370d49 models: fix exception in api_attributes.
Fixup bug in eacb4d4df when calling `api_attributes` on an object that
doesn't have a policy (its policy inherited from ApplicationPolicy).
2020-06-10 18:16:58 -05:00
evazion
8a2ae91ff2 tests: skip video file tests if ffmpeg isn't installed. 2020-06-10 18:07:54 -05:00
evazion
15423e0b7b tests: add progress bar to test output.
Add minitest-reporters gem. Replace the default output of `bin/rails
test` with a progress bar. The default output just emits periods for
passed tests, which makes it hard to tell how long tests will take and
causes test runner output on Github to appear to hang. The web console
on Github is line buffered, but the default test runner doesn't normally
emit newlines (unless a test fails), so the output can hang for a long
time.
2020-06-10 17:52:33 -05:00
evazion
5e63a7cf77 Add test workflow. 2020-06-10 17:52:13 -05:00
evazion
8b5b320be7 docker: fix file permission problems.
Store the app in /home/danbooru/app instead of in /app so that we have
permission to write inside the app dir. /app was owned by root, which
prevented the danbooru user from writing to it.
2020-06-09 17:50:47 -05:00
evazion
15799f8af7 Fix #4260: Unable to replace cdn.donmai.us images?
Bug: Replacing posts hosted on cdn.donmai.us didn't work.

Cause: Original files on cdn.donmai.us are hosted under /var/www/danbooru/original/, but replacements
were trying to store them directly under /var/www/danbooru, which failed with a permission error.
We were trying to store them in the wrong directory because we didn't respect the `original_subdir`
option when generating file paths.
2020-06-09 15:57:43 -05:00
evazion
20abd8a5fd Fix build failure in nokogumbo.
Nokogumbo-2.0.2 fails to build when Nokogiri-1.11.0 is installed.
Nokogiri introduced some changes that are apparently incompatible with
Nokogumbo.

ref: https://nokogiri.org/CHANGELOG.html#versioninfo-and-the-output-of-nokogiri-v
2020-06-09 13:20:46 -05:00
evazion
8b5ffb4c43 uploads: allow admins to upload videos more than 2 minutes long.
At some point the ability for admins to bypass the video length
restriction got lost.

ref: https://danbooru.donmai.us/forum_topics/14647
2020-06-09 03:08:06 -05:00
evazion
d002701bc1 Merge pull request #4494 from nonamethanks/fix_deviantart_api_downloads
Deviantart: fix api downloads
2020-06-09 01:37:03 -05:00
evazion
1ea0141ae1 Merge pull request #4499 from BrokenEagle/fix-4408
Fix notes having absolute coordinates upon creation
2020-06-09 01:36:44 -05:00
evazion
38f385d1ca js, css: fix eslint and stylelint warnings. 2020-06-09 01:35:44 -05:00
evazion
b1f22df4ab Upgrade ruby version to 2.7.1. 2020-06-09 01:35:40 -05:00
evazion
470c3edd94 Upgrade ruby gems and yarn packages. 2020-06-09 01:21:56 -05:00
evazion
3a8d894154 Merge pull request #4498 from danbooru/dependabot/bundler/websocket-extensions-0.1.5
build(deps): bump websocket-extensions from 0.1.4 to 0.1.5
2020-06-09 01:11:41 -05:00
evazion
f1581789ac Merge pull request #4500 from danbooru/dependabot/npm_and_yarn/websocket-extensions-0.1.4
build(deps): bump websocket-extensions from 0.1.3 to 0.1.4
2020-06-09 01:10:49 -05:00
evazion
3033bb4530 Update danbooru Dockerfile.
Split into build stage and runtime stage to reduce image size.
2020-06-09 01:07:42 -05:00
evazion
eacb4d4df3 models: factor out api_attributes to policies.
Refactor models so that we define attribute API permissions in policy
files instead of directly in models.

This is cleaner because a) permissions are better handled by policies
and b) which attributes are visible to the API is an API-level concern
that models shouldn't have to care about.

This fixes an issue with not being able to precompile CSS/JS assets
unless the database was up and running. This was a problem when building
Docker images because we don't have a database at build time. We needed
the database because `api_attributes` was a class-level macro in some
places, which meant it ran at boot time, but this triggered a database
call because api_attributes used database introspection to get the list
of allowed API attributes.
2020-06-08 18:38:02 -05:00
evazion
b6ed63841d footer: fix exception if git hash isn't defined.
The git hash may be undefined when running in a Docker container.
2020-06-08 18:12:32 -05:00
evazion
6d78d22571 Update docker test configuration. 2020-06-07 17:14:41 -05:00
dependabot[bot]
1f16ec67ba build(deps): bump websocket-extensions from 0.1.3 to 0.1.4
Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/faye/websocket-extensions-node/releases)
- [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md)
- [Commits](https://github.com/faye/websocket-extensions-node/compare/0.1.3...0.1.4)

Signed-off-by: dependabot[bot] <support@github.com>
2020-06-06 22:52:37 +00:00
BrokenEagle
6f7530533a Fix notes having absolute coordinates upon creation
Notes are not given percent coordinates when created, however moving
or resizing would update the coordinates to percentage. This is why
it was appearing as if the type of coordinates given were random.
2020-06-05 21:53:00 +00:00
evazion
aa9d34a3f0 config: make danbooru_local_config.rb optional.
Make it so that if danbooru_local_config.rb doesn't exist, we continue
with the default config instead of failing.
2020-06-05 15:49:51 -05:00
dependabot[bot]
6e265ffa60 build(deps): bump websocket-extensions from 0.1.4 to 0.1.5
Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-ruby) from 0.1.4 to 0.1.5.
- [Release notes](https://github.com/faye/websocket-extensions-ruby/releases)
- [Changelog](https://github.com/faye/websocket-extensions-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/faye/websocket-extensions-ruby/compare/0.1.4...0.1.5)

Signed-off-by: dependabot[bot] <support@github.com>
2020-06-05 15:57:14 +00:00
evazion
82c09858f2 Remove unused data attributes from <body> tag.
Fixup for 647556761.
2020-06-03 11:51:21 -05:00
evazion
647556761b Fix antiproxying (again).
Fuck it, just hardcode it. They rewrite certain parts of our markup so
we can't rely on anything in the html.
2020-06-02 23:30:15 -05:00
evazion
bfa76abb56 layouts/default: move <script> tag from header to footer.
* Inline Javascript in the <head> is a minor bottleneck because it
  blocks page rendering.
* Fix antiproxying protection (proxy sites like to strip <script> tags
  from the header).
2020-06-02 22:09:44 -05:00
evazion
91640447c0 Fix antiproxying config options.
Don't embed config options directly in Javascript. Including them in the
Javascript forces us to recompile the Javascript whenever these options
change, which requires us to redeploy the entire site instead of just
restarting the app server.
2020-06-02 20:50:39 -05:00
evazion
18ce552dae tests: fix upload controller tests.
We can't use the name `test_file_upload` because then the helper method
gets treated like it's a test case.
2020-06-02 18:25:45 -05:00
evazion
276f23ba8d config: refactor remove_tag_after_replacement? config option. 2020-06-02 18:25:45 -05:00
evazion
47e6821a31 config: remove customize_new_user config option. 2020-06-02 18:25:45 -05:00
evazion
484eacfd3b config: remove is_unlimited_metatag? config option. 2020-06-02 18:25:42 -05:00
evazion
9997db44d8 config: remove banned_ip_for_download? option.
* Remove `banned_ip_for_download?` config option. This isn't something that usually needs
  to be configured.
* Replace the `ipaddress` gem with `ipaddress_2`. The `ipaddress` gem has several methods
  we need (`link_local?`, etc) that are only available in master because the gem hasn't had
  an official release in several years. `ipaddress_2` is a fork that is more actively
  maintained.
2020-06-02 15:32:19 -05:00