Commit graph

767 commits

Author SHA1 Message Date
Omar Bahareth
dca66bd6a8 Rate limit daily user follows to 500 (#4647) [deploy]
* Rate limit daily user follows to 500 per day
Return an error in `POST /follows` JSON response when a user tries to follow more than 500 accounts in a single day.

Other Changes:
- Add a spec for follows#create.

* Turn daily account follow limit into an env var

* Avoid executing today follow count query when possible
user.following_users_count is a counter cache on how many users the person is already following, so if it's less than the limit we don't need to run the query and can just return it instead.

* Simplify today follow count query
Stop needlessly checking into the future, only check from the beginning of the day until now.

* Raise account follow limit error if followable_id count is over limit
Other changes:
- Always return JSON, the `respond_to` block from before was unnecessary since this endpoint always returns JSON.
- Rescue `DailyFollowAccountLimitReached` on the method and remove begin block, since the error can be raised from two places in the same method.

* Index created_at on users table

* Make adding created_at index on users table happen concurrently

* Rename DAILY_ACCOUNT_FOLLOW_LIMIT to RATE_LIMIT_FOLLOW_COUNT_DAILY

* Add RATE_LIMIT_FOLLOW_COUNT_DAILY to Envfile

* Move RATE_LIMIT_FOLLOW_COUNT_DAILY from env var to ApplicationConfig
2019-11-06 16:24:43 -05:00
rianadon
47ca9b5139 Wrap <figcaption> elements and content inside <figure> elements (#4645) 2019-11-06 15:05:45 -05:00
Colby Melvin
4531679c23 fix tag input swallowing numeric keycodes [deploy] (#4283)
* fix tag input swallowing numeric keycodes

* add AR validation for Tags class

* allow whitespace in Tag.name

* fix specs

* whitespace

* reformat
2019-11-05 16:20:34 -05:00
Mike Rogers
cf475779d0 Setting width & height attributes to SVGs on articles#show page (#4705)
* Adding spec around adding width/height to images

* Adding width/height to svgs on article page

* Improving the englishing of the test description

* Re-read final test description, this felt the clearest

* Just checking attriutes are present - not to fussed about much else
2019-11-05 13:13:44 -05:00
aRtoo
b421ad908b Add JSitor liquid tag (#4657) [deploy]
* Request change
- Added specific error message
- changed jsitor to JSitor
- changed JSITOR_URL constant to URL_REGEXP
- added space between URL_REGEXP and initialize method

* created jsitor liquid tag
- created a jsitor_tag.rb for jsitor liquid core
- created partial (_jsitor.html.erb) for jsitor liquid tag

* created test for jsitor liquid tag
- created spec for jsitor liquid tag
- generated jsitor_liquid_tag.approved.html

* added suggestion change
- removed regex
- change the full link to embeddable id
- removed dead code(methods) due to change logic
- removed checking of link since embeddable id will be parse as string
- removed parts of the test
- change the guide explanation

* Added lazy loading on iframe
2019-11-05 09:43:52 -05:00
Andy Zhao
85d8f52789 Hide a blocked user's content [deploy] (#4678)
* Hide blocked users' content appropriately

* Use RESTful create route

* Update functionality to block the user

* Fix specs for new route

* Use const instead of var

* Add noopener and noreferrer

* Remove caching for blocked user ids

* Add new rule for lack of noopener noreferrer

* Update snapshot
2019-11-04 14:47:26 -05:00
rhymes
027dbb027b Return 401 instead of 500 when a channel is blocked (#4721) 2019-11-04 10:39:18 -05:00
Molly Struve
00e3ee811b Use ActiveSupport::Cache::RedisCacheStore As RedisRailsCache (#4676) [deploy] 2019-11-01 12:19:12 -04:00
Mohab Abd El-Dayem
2c80e9da42 Make The Default Email An Enviroment Variable. (#4677)
* Make the default email an enviroment variable

* Added spaces in Envfile for readability
2019-11-01 09:03:06 -04:00
Molly Struve
cbc85100e3 Create RedisRailsCache Object to Mimic Rails.cache And Apply (#4667)
* Create RedisRailsCache object to mimic Rails.cache

* Do not use prefix _ for a variable that is used

* dont shadow outer local variable
2019-10-31 12:12:21 -04:00
Huynh Tan
b6a731276e Fix answers from other stackexchange sites have the wrong link (#4615) [ci skip] 2019-10-30 15:01:29 -04:00
Brad Pauly
b59aba415d ArticlesController#feed refactor (#4498)
* Move query details into model.
Reorganize filtering initial results by params.

* Fixups from feedback.
2019-10-30 12:35:53 -04:00
Omar Bahareth
41463a7264 Deduplicate giphy_img? function and add tests (#4590)
* De-duplicate giphy_img? function in favor of a tested service.
Add a tested `GiphyService` and move `giphy_img?` function to it.
Make `labor/markdown_parser.rb` and `models/html_variant.rb` use the service version of the function.

* Refactor GiphyService into Giphy::Image class
Based on comments from @rhymes, I've changed this into a `Giphy::Image` class sincethe repo is currently being moved away from `XYZService` objects for namespacing and organization purposes.

* Fix typo

Update describe case to mention the current method name.
2019-10-30 11:40:17 -04:00
rhymes
36d1df7f49 Routine rubocop lint fixes (#4638) [ci skip] 2019-10-30 10:46:57 -04:00
Andy Stabler
198efec024 Refactor collection spec (#4597) [ci skip] 2019-10-30 10:32:41 -04:00
Ben Halpern
ec6d66018f
Add some html to internal articles and new internal view (#4636)
* Add some html to internal articles and new internal view

* Add check for article existence for buffer updates

* Change arrays to unions
2019-10-28 19:09:24 -04:00
aRtoo
05cfe16e1c Fix comment author being notified when mentioning itself (#4456)
* added a condition to check if owner of the comment is in mentions

* added a test to check if comment owner can mention self

* fixed metion test by:
  - adding a second user to simulate a owner of a comment
  - change the user on comment to owned by newly created user
2019-10-25 10:23:45 -04:00
rhymes
d6d251e9ce Remove unused spec support BackgroundJobs (#4464) [ci skip] 2019-10-24 16:49:45 -04:00
rhymes
8989a52aba Strip EXIF and GPS data from uploaded images (#4450)
* Add specs for ArticleImageUploader

* Add specs for BadgeUploader

* Add specs for CoverImageUploader

* Add specs for ProfileImageUploader

* Refactor uploaders to inherit from BaseUploader

* Strip EXIF and GPS data from uploaded images

* Add ImageMagick to the docs

* Protect strip_exif
2019-10-24 16:35:10 -04:00
rhymes
c79d384500 Fix warning on missing Faker keyword argument (#4574) 2019-10-24 14:43:05 -04:00
Nadiya Karachevska
df857d860a Fix API inconsistencies between articles 'index' and 'show' (#4560)
* Fix API inconsistencies between articles 'index' and 'show'

* Update API docs; revert tags from articles index

* Fix specs

* Update specs
2019-10-24 11:56:55 -04:00
Fabbri Paolo
89e893f157 Fix rubocop detected offenses (#4552)
* Run Inspecting 1050 files
....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................C.....................................................................................................................................................................................................................................................................................................

Offenses:

spec/models/article_spec.rb:195:7: C: RSpec/NestedGroups: Maximum example group nesting exceeded [4/3]. (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups)
      context "when description is empty" do
      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1050 files inspected, 1 offense detected to fix autofixable errors

* Refactor  to correct test

it was braking the rule RSpec/NestedGroups: Maximum example group nesting exceeded [4/3]. (http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NestedGroups)

* Run `rubocop --auto-gen-config` to regenrate `.rubocop_todo.yml`
2019-10-24 11:53:03 -04:00
Ben Halpern
4ea7b03727
Add new font and theme config, plus new navbar config option (#4462)
* Initial changes for some new themes/fonts/etc.

* Add basic navbar config

* Finalize navbar config

* Make config_navbar non nullable

* Add dark_theme? to user decorator
2019-10-24 08:38:46 -04:00
Andy Zhao
e6809d8e23 Fix logic error with creating comment block (#4566)
* Fix logic error with creating comment block

* Add additional test for more exercising
2019-10-23 18:32:37 -04:00
Aleksandr
80316818d5 Fix state=all 500 error bug (#4525) [ci skip] 2019-10-23 17:19:47 -04:00
Andy Zhao
73caa9a864 New Feature: Block Users (#4411)
* Prevent need for eager loading

* Add initial implementation of user block

* Remove debugger oops

* Add index and foreign keys for user_block table

* Use private method instead of exists

* Move channel handling logic to service object

* Update styling a bit

* Use profileDropdown file for future proofing

* Remove commented out code

* Render json: { result } for all endpoints

* Add statuses for sad paths

* Add better sad path handling in the JS

* Remove accidentally committed spec file

* Don't wait for DOM to load block button

* Use equality for accuracy in slug query

* Add status code for unauthorized requests

* Add missing comma sigh
2019-10-23 17:14:28 -04:00
Ryan Palo
a00d1eb0d2 Refactor ArticleHelper#get_host_without_www (#4558) [ci skip]
Also add specs for it
2019-10-23 14:36:32 -04:00
Branko Arnaudovski
efbb108061 Implement Moderators audit logs (#3449) 2019-10-23 10:30:45 -04:00
rhymes
d61f8a36a6 Remove Chrome version from Travis.yml (#4555) [ci skip] 2019-10-23 09:15:23 -04:00
Tudor Pavel
d54442f17e Bump Chrome Driver version to fix Travis CI builds (#4554) [ci skip] 2019-10-23 08:20:31 -04:00
Nadiya Karachevska
4dad407289 API: Add pagination to articles (#4483)
* Add pagination to articles

* Refactoring

* Update specs
2019-10-22 12:41:00 -04:00
Mac Siri
7b614006a5
Move all internals request spec under internal namespace (#4495) [ci skip] 2019-10-21 16:38:06 -04:00
rhymes
0c6f34bb2a Add more specs for events (#4444) [ci skip] 2019-10-18 10:30:07 -04:00
Mac Siri
d976eb7ab6 Create InternalPolicy (#4380)
* Ensure verify_authorized in internal

* Create internal_policy

* Replace ArticlePolicy usage with InternalPolicy

* Replace BufferUpdate&CommentPolicy with InternalPolicy

* Remove verbose authorize_admin

* Forgot to remove coresponding specs

* Create specs for InternalPolicy

* Expand policy access on internal's broadcast

* Refactor

* Create shared spec

* Create request specs

* Add additional test cases
2019-10-17 14:21:43 -04:00
Anna Buianova
41ba46623c Increase redirects limit when fetching podcasts (#4479) 2019-10-17 11:24:29 -04:00
Araslanov Evgeny
02a75b6efa Remove unused methods _without_delay (#4366) [ci skip] 2019-10-16 10:35:49 -04:00
rhymes
9c76663e1a Fix broken error interface in Article creation API (#4458) 2019-10-16 09:02:26 -04:00
Akshay Arora
9b5f57db0e Fixed Leave organization not working (#4387) (#4420)
* Fixed Leave organization not working

* Added named route for users_leave_org
2019-10-15 18:04:16 -04:00
Bolarinwa Balogun
a6b51888c5 Improve error message in Api::V0:ArticlesController#create (#4417) 2019-10-15 16:49:26 -04:00
Araslanov Evgeny
7de692156c Add ChatChannels::IndexingJob (#4317) [ci skip] 2019-10-15 16:13:10 -04:00
Ben Halpern
9299f9500d
Update feed to have popular post stick around less (#4413) 2019-10-14 12:34:11 -04:00
Alessandro Diogo Brückheimer
c8b6c9c095 Prepend non-url paths with https://dev.to (#4306) 2019-10-11 12:34:42 -04:00
Luke Jones
dfed6de2da Add post as an alias to the link liquid tag (#4353)
* link_tag alias + test added

* fixed the failing test and added change to editor guide
2019-10-11 08:46:02 -04:00
rhymes
e461f0d799 Routine rubocop fixes after gem update (#4309)
* Regenerate rubocop todo

* Fix outstanding problems

* Fix Style/FormatStringToken

* Final update to rubocop todo file

* Set RSpec/ExampleLength to max 10 and regenerate todo file
2019-10-10 17:27:01 -04:00
Huynh Tan
63dbfe79fe Add a proper error message for Link Liquid Tag (#4341) 2019-10-10 15:44:20 -04:00
Austen Madden
ae22dc93a9 Fix broken job specs (#4281)
* Fix broken job specs

Many job specs were putting their assertions inside a block provided to
ActiveJob's perform_now. Unfortunately, this syntax does not error and
simply ignores the provided block.

The tests were therefore not executing their assertions. As a result
many of them were actually broken to begin with. Many used incorrect
stubbing, were trying to stub instances of models that wouldn't actually
be returned by ActiveRecord queries, etc.

This commit fixes the syntax and does it's best to fix the tests. Many
of these assertions/spec could use more TLC, but this work at least gets
them passing/executing.

* Avoid time comparison precision issues

* Implement review feedback

Adds negative test cases for when record is not found/nil. Also some
formatting changes as I was paying more attention to the rubocop setup
now.

* Add without article context to job spec

* Remove unused lets
2019-10-09 16:05:32 -04:00
Michel
7d530cf002 Fix invalid anchored links due to "//" prefix. (#4340) 2019-10-09 13:57:58 -04:00
rhymes
54047f2292 Use a bigger sample for badges titles (#4334) 2019-10-09 13:13:26 -04:00
Duc Nguyen
2ebe70039a Feat: #3498 Display episode's published_at (#4272)
* feat: #3498 Display episode's published_at

* feat: #3498 Move methods to decorator

* feat: #3498 Add check if published_at present

* feat: #3498 Add testcase for showing published_at

* Fix build failure #3498

https://travis-ci.com/thepracticaldev/dev.to/builds/130734935

* feat: #3498 Fix testcase failed on Travis 130738295

* feat: #3498 Address comments on PR #4272

* feat: #3498 Delete unused

* feat: #3498 Refactor the use of decorate
2019-10-08 17:06:46 -04:00
Araslanov Evgeny
14796a9b84 Fix how white space is detected in frontmatter (#4265) 2019-10-08 16:53:10 -04:00