Commit Graph

55 Commits

Author SHA1 Message Date
Albert Yi
6839249e9d add logic for persisting pixiv sessions in tests 2018-05-10 13:59:57 -07:00
Albert Yi
79ea6f7e6c Add Docker and Travis config files to enable CI tests
Also fixes some Rails 6.0 deprecation warnings
2018-05-09 09:56:38 -07:00
r888888888
abce4d2551 Raise error on unpermitted params.
Fail loudly if we forget to whitelist a param instead of silently
ignoring it.

misc models: convert to strong params.

artist commentaries: convert to strong params.

* Disallow changing or setting post_id to a nonexistent post.

artists: convert to strong params.

* Disallow setting `is_banned` in create/update actions. Changing it
  this way instead of with the ban/unban actions would leave the artist in
  a partially banned state.

bans: convert to strong params.

* Disallow changing the user_id after the ban has been created.

comments: convert to strong params.

favorite groups: convert to strong params.

news updates: convert to strong params.

post appeals: convert to strong params.

post flags: convert to strong params.

* Disallow users from setting the `is_deleted` / `is_resolved` flags.

ip bans: convert to strong params.

user feedbacks: convert to strong params.

* Disallow users from setting `disable_dmail_notification` when creating feedbacks.
* Disallow changing the user_id after the feedback has been created.

notes: convert to strong params.

wiki pages: convert to strong params.

* Also fix non-Builders being able to delete wiki pages.

saved searches: convert to strong params.

pools: convert to strong params.

* Disallow setting `post_count` or `is_deleted` in create/update actions.

janitor trials: convert to strong params.

post disapprovals: convert to strong params.

* Factor out quick-mod bar to shared partial.
* Fix quick-mod bar to use `Post#is_approvable?` to determine visibility
  of Approve button.

dmail filters: convert to strong params.

password resets: convert to strong params.

user name change requests: convert to strong params.

posts: convert to strong params.

users: convert to strong params.

* Disallow setting password_hash, last_logged_in_at, last_forum_read_at,
  has_mail, and dmail_filter_attributes[user_id].

* Remove initialize_default_image_size (dead code).

uploads: convert to strong params.

* Remove `initialize_status` because status already defaults to pending
  in the database.

tag aliases/implications: convert to strong params.

tags: convert to strong params.

forum posts: convert to strong params.

* Disallow changing the topic_id after creating the post.
* Disallow setting is_deleted (destroy/undelete actions should be used instead).
* Remove is_sticky / is_locked (nonexistent attributes).

forum topics: convert to strong params.

* merges https://github.com/evazion/danbooru/tree/wip-rails-5.1
* lock pg gem to 0.21 (1.0.0 is incompatible with rails 5.1.4)
* switch to factorybot and change all references

Co-authored-by: r888888888 <r888888888@gmail.com>
Co-authored-by: evazion <noizave@gmail.com>

add diffs
2018-04-06 18:09:57 -07:00
evazion
d089be9f8a tests: fix upload tests. 2018-03-20 19:49:58 -05:00
evazion
f0bf1bc66e posts: use storage manager to backup files.
* Perform backups synchronously inside `distribute_files` instead of
  asynchronously in `queue_backup`. Asynchronous backups assumed that
  files are stored on the local filesystem, which isn't true in general.

* Remove obsolete backup service classes.
2018-03-20 19:49:06 -05:00
evazion
b0c7d9c185 Add storage managers (local, sftp, s3, hybrid). 2018-03-20 19:49:06 -05:00
evazion
46b0f9e6d6 Update dotenv.
dotenv-2.2.1 no longer loads .env.local in the test environment. Load it
manually for backwards compatibility.
2018-01-20 19:04:48 -06:00
evazion
4f543671a2 tests: move test/helpers to test/test_helpers.
The Rails convention is for test/helpers to be used for testing the view
helpers in app/helpers. We were using it to store certain utility
methods instead. Move these to test/test_helpers so that test/helpers
can be used for its intended purpose.
2018-01-14 16:11:15 -06:00
r888888888
4a80d6c337 refactor User#validate_sock_puppet to disable for tests 2018-01-02 14:32:38 -08:00
evazion
fcec99405c Fix failure in rake db:migrate on fresh install (#3443).
Create the DanbooruBot account in db/seeds.rb instead of in an
initializer. Move the old db/seeds.rb to db/populate.rb.

Fixes a bug introduced in e2eb45a. Creating DanbooruBot in an
initializer was wrong because in a fresh install the users table doesn't
exist yet. This caused `rake db:migrate` to fail.
2017-12-21 12:08:08 -06:00
r888888888
ba517af1db fix functional tests 2017-11-20 16:30:07 -08:00
evazion
f8ed7d4357 tests: fix HTTP requests failing due to webmock (#3039).
Fixes failures in source tests caused by Webmock disabling non-stubbed
HTTP requests by default.

https://github.com/bblimke/webmock#real-requests-to-network-can-be-allowed-or-disabled
2017-07-01 12:22:36 -05:00
r888888888
d7690d24b0 fixes #3039 2017-06-29 16:05:01 -07:00
evazion
5684ba3b1d tests: factor out assert_downloaded to DownloadTestHelper. 2017-06-21 21:10:07 -05:00
evazion
a844a1daf4 posts: fix expunging posts not deleting files.
Fix expungement to ignore the "file still in use" check.
2017-06-14 21:31:24 -05:00
evazion
c0e5c400a7 tests: fix tests for Rails.cache. 2017-04-16 16:48:36 -05:00
r888888888
6bd03ee4db fix tests 2017-02-21 15:04:55 -08:00
Albert Yi
5404c1d231 implement postarchive 2017-02-21 13:40:52 -08:00
evazion
e26fb61ee9 tests: add explore/posts controller tests. 2017-02-06 18:48:36 -06:00
evazion
8c75f74ca5 tests: update simplecov config. 2017-02-04 22:17:39 -06:00
evazion
e8cf417e9c tests: update gems to latest versions.
Also fix a few things that broke under shoulda-matchers 3.1.1.
2017-02-04 22:17:15 -06:00
evazion
dd5974bf8c test_helper.rb: use MemcacheMock. 2017-02-04 17:18:52 -06:00
evazion
9b16c45edc test_helper.rb: factor out upload test helpers. 2017-02-04 17:18:52 -06:00
evazion
1511118bba test_helper.rb: remove unused assert_authentication_* helpers. 2017-02-04 17:18:51 -06:00
evazion
beddc34958 tests: set Delayed::Worker.delay_jobs = false globally. 2017-02-04 17:18:51 -06:00
Albert Yi
0ea7d78584 remove usage of vcr cassettes; delete unused fixtures; fix some broken unit tests 2016-12-28 15:47:28 -08:00
r888888888
fc7afd44ea refactor source pixiv test
refactor pixiv download tests
refactor upload test
refactor nico seiga test
refactor twitter tests
2016-09-28 11:25:29 -07:00
r888888888
58aa5c6d66 fix tests 2016-05-28 14:08:44 -07:00
r888888888
66dd4f072e update tests 2015-06-02 19:20:48 -07:00
r888888888
c92c32ecda fix tests 2015-02-15 12:23:53 -08:00
r888888888
6233bfd40e fix tests 2015-02-10 18:37:23 -08:00
r888888888
ace7e6abff fix warnings 2014-12-10 16:23:58 -08:00
evazion
57bb51621e Add debugger gem.
Fix random VCR failures in Pixiv tests.

Sometimes tests randomly fail because the PHPSESSID they use in their
HTTP requests to Pixiv is different than the one that was originally
recorded by VCR. This causes VCR to complain that the requests don't
match.

This is caused by the PHPSESSID being globally cached in Memcache.
Depending on the order the tests run in (which is random), one set of
tests can use a PHPSESSID that was recorded for a /different/ set of
tests.

Improve Pixiv URL matching.

* Allow URLs that are missing the http:// part. These are sometimes seen
  in artist entries.
* Ignore URLs from random Pixiv domains such as dic.pixiv.net,
  blog.pixiv.net, etc. These are also sometimes in artist entries.

Improve normalize_for_artist_finder! URL matching.

* Normalize www.pixiv.net/stacc/username URLs.
* Correctly normalize URLs that are missing the illust ID part on the end
  (i.e. http://i2.pixiv.net/img04/img/syounen_no_uta/). These are common
  in artist entries.

Match URLs strictly when normalizing for artist entries.

Only normalize Pixiv URLs that strictly match a known format. Pass any
unrecognized URLs through without attempting to normalize them, just to
be safe.

Normalize URLs when saving artist entries.
2014-12-03 13:16:05 -08:00
r888888888
177ef0ebcc fixes #2307 2014-11-19 17:17:26 -08:00
evazion
268f79c3d9 Make VCR disallow unexpected HTTP requests.
This makes it so that tests fail when they make HTTP requests they
aren't expected to. Update these tests so that they use VCR like they
should.
2014-10-04 12:45:37 -05:00
r888888888
60d3bcf251 update version 2013-06-05 15:37:33 -07:00
r888888888
4dff618863 Use webmock instead of fakeweb for VCR; Fix tests; Use Timecop to speed up tests previously using sleep; Move artist rename into seperate operation 2013-05-24 12:59:13 -07:00
r888888888
5547f0937a switch vcr web backend to fakeweb, add vcr support for nico seiga tests 2013-05-03 16:24:10 -07:00
r888888888
850270dafa add vcr cassettes for pixiv tests 2013-04-30 17:35:24 -07:00
albert
2ac22d07cd implement api limiting 2013-03-20 16:35:35 -07:00
小太
cba839ba76 Kill trailing whitespace in ruby files 2013-03-19 23:10:10 +11:00
albert
b030cbf6ac upgraded to rails 3.2.1 2012-01-27 17:15:46 -05:00
Robin Liao
0690733247 Mocking out a fake Memcached so we can run our tests without a running memcache server 2011-09-03 04:38:07 -07:00
albert
ebee1eb665 fixed upload tests 2011-08-23 18:33:27 -04:00
albert
f48000a8b5 got rid of removedpost, restore classic is_deleted mechanics 2011-02-12 17:37:48 -05:00
albert
46164eab4f finished dmails and favorites functional tests 2010-12-05 22:27:45 -05:00
albert
484ff696e2 fixed jrails, fixed deprecation warnings 2010-10-27 13:40:50 -04:00
albert
5610731b35 sync 2010-08-18 18:42:33 -04:00
albert
06a959a9fd fixed test:units rake task 2010-03-18 18:29:41 -04:00
albert
9eb578927c added limit methods to user, more work on post views 2010-03-12 15:18:30 -05:00