* Skips scheduled posts in featured post count
* Allows removing super_admin role
* adds namespace resolution op
* Adds pundit policy
* Adds rspec for role policy
* Fixes test cases and minor refactoring
* Removes dead code
---------
Co-authored-by: Lawrence <lawrence@forem.com>
* Prepare: relocate user suggestions
* Prepare: relocate users suggestion service -> query
* Organization query for orgs with above-average scores
* Rubocop
* Limit to last 3 weeks
* Tweak recent scope, limit to 5 orgs
* Onboarding routes are also always JSON
* Divide by zero makes NaN means
* Add Orgs suggester into suggestions
* Rubocop
* select distinct orgs
* Fix for weird edge-case with bad local data
* Include type_identifier in JSON payload
* Update follows API to allow org_ids as input
* Update onboarding front-end to distinguish users/orgs
* Fix: i18n issues
* Fix: type_identifier in json output
* Fix: distinct is weird
* Fix: JS linter
* Continue tweaking front-end
* Audit import order
* Cleanup @todo note
* Try renaming controller action
* Move Article average calculation to postgres and fix math
* Refactor decorated type_identifier
* Refactor SuggestProminent, return more orgs, fix spec math
* Use FeatureFlag for organization suggestions
* This might fix the jest
* feat: remove initializeSponsorshipVisibility and related code
* feat: remove sponsorships from sidebar
* feat: remove sponsorships from the admin - route, controller, view, spec
* feat: remove the admin menu item
* feat: remove the i8n for admin sponsors controller
* feat: sponsorship decorator was not being used anywhere
* feat: sponsorship slack messenger was not being used anywhere
* feat: remove the sponsorship_headline that gets configures on the admin
* feat: remove the /sponsors page
* feat: remove renedring of single_sponsor partial and associated partials
* feat: remove the navigation link rake task for sponsors
* feat: remove sponsorship from tags
* feat: remove i8n constants used
* remove sponsor references in text to the privacy page
* feat: remove the sponsorship detail from the organization page
* feat: remove the sponsors css that was used for app/views/pages/sponsors.html.erb
* feat: remove the sponsorship i8n that was used in the slack messengers
* feat: swap out the decorators to use Article as an example
* feat: remove spec to show sponsors on home page
* feat: update the specs to use Article Decorator instead of the Sponsorship Decorator
* fix: use direct and not all
* fix: remove tests for tag sponsorship
* fix: remove organization sponsorship test
* feat: remove more i8n
* remove unused css from app/views/organizations/_sidebar_additional.html.erb
* feat: remove sponsorship relationship from tag and organization
* remove seed
* feat: remove all Sponsor related specs
* feat: remove model, associated i8n and specs
* feat: remove sponsor from navbar
* feat: add a guard clause if we're unable to constantinize the purchase_type
* feat; remove sponsorship related tests
* feat: remove sponsorship relationship
* feat: remov especs related to sponsorship
* feat: remove tag sponsorship validation
* feat: remove the sponsorship factory
* Make user_id optional for DisplayAdEvent
* Track when DisplayAd is visible to user
* Tidy up a bit
* Deleting a user account should nullify related DisplayAdEvents
* Update tests with new association details
Prior to this commit, we may have left lingering podcast entries that
required manual cleanup. As a bonus, I also added deleting podcasts
when we delete users.
Closesforem/forem#18041
In addition I adjusted rubocop to not complain about the require method call
```
spec/services/users/delete_spec.rb:1:1: C: \
Style/TopLevelMethodDefinition: \
Do not define methods at the top-level. \
(https://rubystyle.guide#top-level-methods)
require "rails_helper"
^^^^^^^^^^^^^^^^^^^^^^
```
* transliterate when generating attribute names to avoid emptiness
If you enter a non-ascii (non `\w` matching) string as the profile
field label, the attribute name is the empty string.
This causes problems outlined in #16391
To avoid losing user provided data, transliterate (Sterile is the same
tool we're using for Article#title_to_slug) before matching against
the word regex.
If we persist an empty string, or persist a non-`\w` name, the
coordinating regex in Profile::ATTRIBUTE_NAME_REGEX will leave a nil
match and raise NoMethodError (the method missing is for
match[:attribute_name] when match was nil, not Profile - that's the
next commit.
* Guard against nil matches
If an attribute name doesn't match the regex, the match is nil, and
trying to access (nil)[:attribute_name] raises a NoMethodError.
If there was no match, assume profile does not respond to the
selector, and don't handle it in method missing.
* Ensure generated attribute name is valid before saving
This raises a validation error if the generated name (from the label)
would be empty.
It's not an optimal error message (since the user can't see the
internal attribute name) but it prevents persisting broken/empty data
* actually raise error when validating
validate/valid? only return true or false (and set errors on the
object). In order to reject the creation, we need to raise a
validation error, not only call validate. I think this is because the
execution of before_create hooks happens after validation (which is
why the validation was only checked on update, not create).
* Generate an attribute name completely independent of the field label
This prevents mistakenly labeling a field "Class" or "Association" or
one of the other hundred public methods an AR model like Profile
exposes. Since attribute_name will be passed to `profile.public_send`
we really shouldn't build selectors from user supplied inputs.
* Use the admin supplied label in the sidebar
The profile decorator is used in the Users#show page to populate the
sidebar fields. Don't use the attribute name (which we mangled during
creation, and now generate randomly) as the label, use the label.
* Make the label lookup null safe, and filter attributes more
* Update data update script to not expect predictable labels
This is low impact since it ran in july, but we no longer know what
attribute name a label will create.
* Fix moderator spec
"Test Field" label no longer predictably generates :test_field as an
attribute name. Ask the field what it's name is before asking profile
about it.
* Fix profile preview card request spec
Remove the assumption that profile responds to a method name based on
the label for Work and Education fields.
* Update old DUS and its test
This can probably be archived
* Update profile spec to use fields generated attribute names
We used to "know" how attributes were generated from labels. Now we don't.
* update e2e seeds for profile field change
* Don't expect attribute name to be based on the label
* expect created profile fields respond to their attribute name
* Update system test
The label, not the attribute name, is shown on the profile form (the
field has an id related to the attribute name, but the view shows the
mutable/human-readable label).
* Keep the field title lowercase when sending the json preview card
The userMetadata component expects "work" and "education" to be
attributes of the metadata, but the ui_attributes_for() method was
titlizing these (for display).
Ideally we wouldn't have "special purposed" these two field names, but
they're there.
* update profile field by attribute name, not based on label
* Update profile field removal assumptions
We don't know what the method selectors will be, we have to ask.
* remove old test
* Update translations for Education and Work
Since the ui_attributes_for(area:) now gives the label, not the
attribute, we need to match the label of the profile field.
Note to self: this exposes an issue in localizing the custom profile
fields (probably a bigger problem for large, international communities
like DEV than some others, but trying to match static translation
files against user-modifiable database records seems like a problem
we'll see again).
* Empty commit to retrigger buildkite
* Remove profile field migration update scripts
Cloned the specs from the other "remove unused scripts" script.
* Remove unused scripts
The data update script removes the entry from the table (recording
that these have run) - we also want to remove the files (preventing
them from running again).
* remove unneeded spec for removed file
* when translation for header area field not found, use the title
Only Work and Education already have keys in the yml translation file,
and there's not a great (or easy?) way to make multiple translations
on these fields right now.
Since an admin can create a new field, and assign it to the header
area, we can't assume the code has a configured translation key for
this field.
Fallback to the title (we do this in another context already) if
there's no translation.
* PR feedback: Avoid n+1 query for labels
the original implementation of "label_for_attribute" had an n+1 query
looping over each matched key.
Follow suggested improvement and pull labels and attributes at once
from the db and modify the returned hash.
* Downcase title before looking for translation key
This avoids putting "odd" capitalized keys into the yml translation
file
Revert addition of "Work" and "Education" to the users files.
* use a let binding for duplicated test data
* Update app/models/profile_field.rb
prefer SecureRandom.hex for a dashless uuid (instead of removing the dashes).
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
Co-authored-by: Jamie Gaskins <jgaskins@hey.com>
* Don't suggest users for an anonymous visitor to follow
The sidebar raises an error when rendering suggested users for a tag
when the user is signed out.
https://app.honeybadger.io/projects/66984/faults/79342962/
* Assert empty response returned for anonymous requests
* Remove reactions to a user when deleting the user
Fixes#15245
---
I have no idea why `create(:vomit_reaction, reactable: user)` gave a
validation error about category being invalid, but `build().save`
worked fine.
* Move relation details to reaction scope `for_user`
Add a user method to access this by passing self to reaction scope
* Create a moderator when flagging user in factory
This might be a missing requirement in the reactions factory - but
this suppresses an error about invalid category I was getting when
setting a privileged reaction on the user via
create(:vomit_reaction, reactable: user)
Everywhere else it looks like we do this with `user: moderator` (where
there's a trusted user in the surrounding context).
* Move trusted user requirement into vomit_reaction factory
* Add a data update script to remove reactions to deleted users
This cleans up the remaining invalid references and should make the
change in #15249 obsolete (i.e. we don't need to limit the view to
exclude items that no longer exist).
* Remove Connect
* Remove more Connect specs
* Remove a lot more Connect code
* 🚮
* It all has to go
* Explicitly add httpclient
* Update application layout
* Remove messages association from User
* Start fixing specs
* reintroduce util function and refactor references
* Remove Connect Cypress test
* Fix more specs
* Remove Connect from listings
* Ignore contact_via_connect column on listings
* Remove contact_via_connect usages
* Ignore mod_chat_channel_id on tags
* Drop Connect tables
* Remove email_connect_messages from user notification settings
* Re-add httpclient 2.8.3
This was mistakenly removed as a merge conflict
* Don't need to exclude removed chat channel file
* Remove unneeded style for chat channels
* Remove unneeded channel list prop type
* Remove chat channels index/connect-link from getPageEntries
* Re-add comment from httpclient in Gemfile
* Remove connect references from mailers
Tag Moderators no longer have a chat channel
No longer will users be notified about new messages (there won't be
any)
No longer will users be notified about channel invites (you can't
invite anyone anymore)
* Don't configure Pusher and remove PUSHER_* from .env_sample
since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
* Use regex to replace with https
* Refactor a bit
* Update logic to handle edge cases
* url being nil
* url not a valid URL (weak validation, checks for starting
string of http)
* Add new test case for http to https conversion
* Remove hardcoded instances of education field
* WIP Access display_email_on_profile via User Settings
* Remove unused profile column
* WIP Fix reference to bg_color_hex and text_color_hex
* WIP fix issues revealed by systems specs
* WIP fix issues revealed by services specs
* WIP Fix failing tests
* WIP Fix spec failures
* wip
* Move two attributes from controller to decorator
* Update comment
* Match user settings changes
* More consistently use user.tag_line
Even before the profile changes we sometimes used the user.summary
attribute directly but used the user.tag_line method in other places.
* Remove delegation, rename inline concern
* Drop profile columns from users table
* Remove duplicated work display from header
* Update work profile field handling
* Update DUS + spec
* Delegate more carefully
* Update delegation guard
* Adapt for removed delegation
* Undo accidental schema changes
* Fix seeds
* Remove accidentaly change
* Fix User#processed_website_url
* Update guard clause
* Update profile card content
* Add Organization#profile
* Be more conservative with profile fields
* Spec fixes round 1
* Fix typo
* Update spec
* Limit number of header fields and update card content
* Decorate correct model
* Update factory
* Update schema.rb
* Fix validation
* How bad could this possibly be?
* Pretty bad, nevermind
* Remove obsolete code
* Reset profile fields during test runs
* Move profile fields back to before(:suite)
* Spec fixes
* Remove accidentally re-added files
* More spec fixes
* Specs
* Change User#tag_keywords_for_search
* More spec fixes
* Add comment
* Undo accidental schema changes
* Attempt spec fix
* Remove fix attempt
* Fix e2e test
* Update spec
* Remove guard clause
* Remove hardcoded instances of education field
* WIP Access display_email_on_profile via User Settings
* Remove unused profile column
* WIP fix issues revealed by systems specs
* WIP fix issues revealed by services specs
* WIP Fix failing tests
* WIP Fix spec failures
* wip
* Move two attributes from controller to decorator
* Update comment
* More consistently use user.tag_line
Even before the profile changes we sometimes used the user.summary
attribute directly but used the user.tag_line method in other places.
* Remove education
* Add comment
* WIP
* Clean up mostly_work_with
* WIP
* Update work profile field handling
* More work-related changes
* Remove settings_only from display_area enum
* Remove quickfix from _metadata partial
* Remove special attributes
* Remove leftover spec
* Retrieve location from profile, not user
* Profile.special_attributes no longer exists
* Update specs
* More spec fixes
* Update UsersController
* Update UsersController and spec
* Fix e2e seeds
* Minor cleanup
* More e2e seed fixes
* Fix profile field CSV
* Fix e2e seeds
* Move one more attribute in e2e seeds
* Remove duplicate line
* Clear inputs before typing in them
* Fix formatting issues
* Profiles::Update -> Users::Update
* Remove RegistrationsController#resolve_profile_field_issues
* Fix schema.rb
* More cleanup
* Fix specs
* Fix remaining spec
Co-authored-by: Jacob Herrington <jacobherringtondeveloper@gmail.com>
* Rename SiteConfig
* More renaming
* Update spec
* Update mandatory settings mapping
* More renaming
* e2e test fixes
* You have a rename, and you have a rename
* Spec fix
* More changes
* Temporarily disable specs
* After-merge update
* Undo rename for migration
* undo rename of DUS
* Fix DUS
* Fix merge problem
* Remove redundant DUS
* Fix specs
* Remove unused code
* Change wrong class name
* More cleanup
* Re-add missing values to constant
* Fix constant
* Fix spec
* Remove obsolete fields
* Add accidentally removed field
* Update spec
* Move methods from Settings::General to ForemInstance
* Remove unneeded model
* Change mentions of 'site config'
* Change article factory to include a flare tag "discuss"
This removed the css tag - keeping the articles tags count
consistent. If we are checking that articles have tag css exactly
there may be one or two specs changing.
If we assert does not have flare then we will want to adapt that as well.
* Change the tag to follow from css to html
Since we removed "css" from the articles factory, use one that we kept.
* Rename banned and comment_banned roles
* Add data update script to rename roles containing 'ban'
* Add named error for Suspended users
* Update unidiomatic method names
* Rename misc banned to suspended
* Apply suggestions from code review
Co-authored-by: Michael Kohl <me@citizen428.net>
* Add unit tests for suspended methods
This commit also adds TODO comments for removing banned and
comment_banned from the codebase after data update scripts have
successfully run on all of our Forems.
Co-authored-by: Michael Kohl <me@citizen428.net>
* Add a failing test
This is failing because sponsorships are not removed by Users::Delete,
and raises a foreign key constraint error because user.destroy tries
to remove a referenced user.
* When destroying a user, destroy associated sponsorships
There is a `belongs_to` relationship in sponsorships, and a has_many
relationship in Organization, this adds a mirror relation on User with
the equivalent dependent destroy rules.
If an organization is removed, all sponsorships belonging to that
organization are removed too, and now, if a user is removed, all
sponsorships created by that user are removed.
Co-authored-by: djuber <djuber@forem.beta-reduction.com>
* WIP: Adds a Users::RemoveRole service to encapsulate Admin::UsersController#destroy
* Adds #role_display_name helper to application_helper.rb for extensibility
* Adjusts Member is Suspended banner to Member is Banned for consistency
* WIP: Extract Admin::UsersController#destroy into remove_role.rb service
* Cleans up Admin::UsersController#destroy and remove_role.rb service
- Removes unneccessary code from Admin::UsersController#destroy
- Replaces args with keyword args in Admin::UsersController#destroy
- Replaces args with keyword args in remove_role.rb service
- Refactors code to be more extensible and cleaner overall
* Adds a remove_role_spec.rb to test Users::RemoveRole service
* Fix typo in Admin::UsersController#destroy
* Refactors role_display_name helper method and reverts change to banner
* Use #role_display_name in _current_roles.html.erb
* Refactors conditional, names, and adjusts spec to account for refactors
* Raises StandardError if there is an issue with role removal
* Add new table and model
* Store banned user username hash on delete
* Prevent previously banned user from signing up again
* Update method name
* Refactor code and add more specs
* Test improvements
* Don't override existing global flash
* Fix typo
* Update spec description
* Update schema.rb
* More schema.rb fixes
* Simplify spec
* Update migration
* Clean up migration
* Rename method
* Add DataDog counter
* Revisit error handling
* Remove spurious empty line
* Make model name more explicit
* Add missing FKs to BackupData BadgeAchievements BanishedUsers BufferUpdates
* Add relations and specs
* Fix specs
* Trigger Travis CI
* Remove traces of backup_data has it has been removed on master
* Fix trailing whitespace