Commit graph

57 commits

Author SHA1 Message Date
Michael Kohl
5da625cadb
Rubocop fixes (#15892)
* Add missing spaces

* Use filter_map over map + reject/compact

* Simplify FactoryBot calls

* Use to_h with block instead of map + to_h

* Use guard clause
2021-12-28 09:11:41 -06:00
Jeremy Friesen
a40efc6bbd
Refactoring questions asked of user (#15762)
* Refactoring questions asked of user

In this pull request, I'm extracting and normalizing role-based
questions asked of the user.

Prior to this commit, our codebase has asked two very similar questions
of our user model:

- `user.has_role?(:admin)`
- `user.admin?`

In asking `has_role?(:admin)` we are relying on implementation details
of the rolify gem.  In addition, the `has_role?` question asked
throughout controllers or views means that it's harder to create
hieararchies of permissions.

In favoring `user.admin?` as our question, we can use that indirection
as an opportunity to discuss and decide "Should someone with the
`:super_admin` role be `user.admin? == true`?"

The details of this commit is to do three primary things:

1. Ask the `has_role?` questions in "one place" in the code (e.g. the
   `Authorizer` module)
2. Extract the role based questions that are on the `User` model and
   provde backwards compatable delegation.
3. Structure the code so that it's harder to accidentally call
   `user.has_role?` (e.g., make `User#has_role?` and `User#has_any_role?`
   private).

This is related to #15624 and the updates are informed by discussion in
PR #15691.  This commit supplants #15691.

* Refactoring the liquid tag policy tests

* Fixing typo

* Bump for travis
2021-12-21 12:45:12 -05:00
Josh Soref
0403e78f08
Spelling (#15702)
* spelling: access

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: additional

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: administrative

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: aggregate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: assigns

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: attributes

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: autocomplete

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: because

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: between

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: bootstrap

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: calculating

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: captcha

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: character

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: chosen

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: commenter

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: competitor

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: componentize

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: contrast

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: corresponding

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: description

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: destroyed

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: destroys

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: discussion

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: episode

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: escaped

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: evaluates

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: expired

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: explicitly

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: facebook

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: fragment

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: functionality

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: improper

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: incentive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: interfere

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: latest

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: message

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: minimum

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: moderator

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: mouseover

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: mutual

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: nonexistent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: notification

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occasionally

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurrence

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: occurs

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: octokit

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: offset

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: omitted

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: opacity

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: organization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: organizations

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overridden

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: override

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overriding

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: prefill

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: previous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: profile

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: recycling

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: registered

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: repositories

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: rescuing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: response

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: returns

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: second

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: separator

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: services

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: subscriber

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: subscription

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: success

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: successful

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: successfully

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: suppress

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: test

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: thought

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uniqueness

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unknown

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unproductive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unreachable

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unsuccessful

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: utilities

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: utility

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: valid

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: voluntarily

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: vomited

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: website

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: withholding

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2021-12-07 06:59:10 -07:00
Jeremy Friesen
e1bddb5bf8
Replacing User#warned with User#warned? (#15628)
A simply refactor to introduce more idiomatic method names.

Related to #15624
2021-12-01 13:14:16 -05:00
Michael Kohl
09828853f6
✂✂✂ Remove Connect (#14734)
* 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>
2021-11-18 08:21:00 -06:00
Ridhwana
aa6d80bc5d
Only enable user invitations page when SMTP is enabled (#15219)
* first pass of styling of the page

* feat: scroll to the position in the config controller in stimulus

* feat: add the tooltip and a cursor thats not allowed

* feat: add a disabled property for all that needs smtp to be enabled

* feat: update the form styling

* feat: update the form

* specs: update the label name

* fix: syntax error

* chore: update the newline

* spec: test the invitation flow

* fix test

* feat: update the form as per suggestions

* spec: update the tests to match the new workflow

* oops committed debugging code

* chore: add a before to set the smtp_enabled method

* feat: update the boldness and fontsize of the link

* feat: remove size
2021-10-29 17:41:30 +02:00
Michael Kohl
a1f512e49e
✂✂✂ Remove events (#15062)
* Remove events

* Fix schema

* Fix specs

* More removal
2021-10-15 09:31:08 -04:00
Andy Zhao
5c5d37d648
Update admin welcome checklist (#14261)
* Update admin welcome checklist

* Update invite link text in test

* Remove extraneous invite line and period

* Add overview tracking to all links in checklist

* Fix spec to check for proper link
2021-07-28 14:27:17 -04:00
Julianna Tetreault
e1e18aa0aa
[15-Minute Fix] Ensure "Locked Screen" Checkbox Conditionally Renders (#14161)
* Uses Settings::UserExperience.public to conditionally render btn

* Updates landing page-related specs to account for private forem

* Uses Settings::UserExperience in place of ForemInstance in admin_creates_new_page_spec.rb

* Reverts Settings::UserExperience.public? changes throughout codebase
  - Removes any changes to ForemInstance.private?
  - Adds a new helper method, self.invitation_only?
  - Updates self.private? logic

* Updates landing page specs and reverts unnecessary changes
  - Reverts any changes that removed the check for
ForemInstance.private?
  - Updates landingPage.spec.js to use findByRole rather
than findByText

* Reverts a change to admin_manages_pages_spec.rb

* Updates landingPage.spec.js per PR review comment

* Updates #private_forem_or_no_enabled_auth_options and spec

* Uses .invite_only? in _providers_registration_form.html.erb

* Adjusts authenticationSection.spec.js to test that FB is enabled

* Updates necessary specs to check .invitation_only?

* Consistently uses invite_only_mode_or_no_enabled_auth_options
  - Updates all necessary places within the codebase to use
reverted method name, invite_only_mode_or_no_enabled_auth_providers
  - Updates #self.enabled to check ForemInstance.invitation_only?
rather than ForemInstance.private?
  - Reverts change to Facebook assertion within authenticationSection
e2e test

* Removes superfluous .to from authenticationSection.spec.js
2021-07-12 14:14:43 -06:00
Michael Kohl
aa3a9f5314
[15-minute fix] Disable 'Locked Screen' prompt for public Forems (#14029)
* Disable 'Locked Screen' prompt for public Forems

* Fix spec

* Ensure Forem instance is private in Cypress tests
2021-06-30 10:09:38 +07:00
Julianna Tetreault
4d0b9c8ebf
Adds local: true to admin/tags/edit.html.erb remove mod button (#14057)
- Adds local: true to fix broken Admin tag mod removal button
  - Refactors admin_creates_new_tag_spec.rb
2021-06-23 12:34:53 -06:00
Julianna Tetreault
281fdc499c
[15-Minute Fix] Fix Broken Admin Tags #create and #update Forms (#14049)
* Adds name to ALLOWED_PARAMS in Admin::TagsController

* Adds local: true to /admin/tags/_form.html.erb
  - Sets local: true in tags partial for proper
redirects and to properly render flash messages
for both the #create and #update actions

* Adds local: true to the Add Moderator button for tags

* Adds and updates systems specs for tags
  - Updates the admin_updates_tag_spec.rb system spec
  - Adds an admin_creates_new_tag_spec.rb system spec
  - Updates the success flash message in Admin::TagsController
2021-06-23 14:30:17 +02:00
Julianna Tetreault
6b0d2b6173
Uncomments line 26 in admin_manages_organizations_spec.rb (#14051) 2021-06-23 09:22:59 +02:00
Mac Siri
e38196df6f
Create Settings::SMTP (#13943)
* Fix typo

* Add SMTP configs to Settings::General

* Expand Settings's show page

* Expand Settings::General's constants

* Move smtp_enabled? logic to ApplicationMailer

* Apply suggestions from code review

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>

* Add missing descriptions and placeholders

* Remove production guard clause

* Change delivery_method to a callback

* Create Settings::SMTP

* Run migration

* Move constants

* Remove SMTP from Settings::General

* Create SMTPSettingsController

* Add back guard clause

* Change which perform_deliveries configuration to use from

* Update config/environments/production.rb

* Rename migration to singular

* Run migration again

* Fix name

* Alphabetize and add validation for authentication

* Move settings and enabled? logic to Settings::SMTP

* Change after_action to before_action

* Fix broken spec

* Fix broken spec

* Create SMTP specs

* Provide default for port

* Create spec for ApplicationMailer

* Fix broken spec

* Move smtp_enabled?

* Search and replace

Co-authored-by: Ridhwana <Ridhwana.Khan16@gmail.com>
2021-06-14 10:29:43 -04:00
dependabot[bot]
1ea169a351
Bump rubocop-rspec from 2.3.0 to 2.4.0 (#13951)
* Bump rubocop-rspec from 2.3.0 to 2.4.0

Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.3.0 to 2.4.0.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.3.0...v2.4.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Enable new cops, fix violations and refactor specs

* Remove expected "Moderate" text from the /mod page test

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: rhymes <github@rhymes.dev>
Co-authored-by: Dan Uber <dan@forem.com>
2021-06-14 09:27:13 +02:00
Julianna Tetreault
b12ebfa0e5
RFC #74, Pt. 2: Private Forem Landing Page (#13819)
* Adds landing_page checkbox for Landing Page

* Adds landing_page to page_params in Admin::Pages::Controller

* Adds landing_page to admin_manages_pages and admin_creates_pages specs

* Adjusts copy for Landing Page in pages/_form.html.erb

* Places #post_a_job before #privacy in Pages::Controller
  - Ensures that all page-related methods are properly
 alphabetized

* Alphabetizes remaining out-of-order page-related methods
  - Ensures that all page-related methods within the
 Pages::Controller are in alphabetical order, following
 the order of the other methods

* Adds landing_page check to ApplicationController#verify_private_forem

* Adds a single_landing_page validation to the Page model

* Adds a lock.svg to /images and uses it in the pages index

* Adjusts buttons and checkboxes to use crayons class in pages partial

* Ensures that pages/_form.html.erb destroy button uses crayons

* Adds a landing_page validation-related test to page_spec.rb

* Updates #single_landing_page validation and error message

* WIP: Adds JS modal upon landing_page error in pages/_form.html.erb

* Adds a working modal upon error in pages/_form.html.erb
- Removes redundant #single_landing_page validation from Page
- Adds #has_a_landing_page? in place of #single_landing_page
- Conditionally renders the landing_page checkbox in _form.html.erb
- Adds styles to locked screen/landing page modal
- Adds copy to locked screen/landing page modal
- Beings adding buttons to overwrite current landing_page

* Updates the data-modal-selectors and ids in pages/_form.html.erb

* Uses #landing_page_path within pages/_form.html.erb modal
- Adds a link_to to link to the current landing page in the modal
- Adds styles to buttons and link_to in modal

* Adds back single_landing_page validation to Page.rb

* Reverts changes and updates methods within Page.rb
 - Reverts changes to #single_landing_page
 - Refactors #has_a_landing_page? and #landing_page_path
 - Updates div id in pages/_form.html.erb

* Adjusts #single_landing_page error message slightly

* Adds a test for landing_pages in stories_index_spec.rb

* Adds an overwrite attribute to Pages for the modal in _form
  - Fixes anonymous spelling

* Refactors pages/_form.html.erb and cleans up spelling

* Adds a safe operator to landing_page.path in Page
  - Adjusts the placement of the hidden value in pages/_form.html.erb

* Updates styling for Current Locked Screen link

* Adds the ability to overwrite an active landing page on click
  - Adds Admin::PagesController#update_and_overwrite and refactors
AdminPages::Controller#udpate to work with new method
  - Adds a remote attribute, overwrite, to Admin::PagesController
via a hidden_field in pages/_form.html.erb and an attr_accessor in
the Page model
  - Adds a toggleOverwrite() function to pages/_form.html.erb to
toggle the (soon to be hidden) overwrite checkbox in the form --
the checkbox is toggled on button click

* Adds a guard clause to #landing_page_path in Page.rb

* Adds a safe naviagtor to Admin::PagesController#update_and_overwrite_landing_page

* Adds a type and return to Overwrite button to prevent submit

* Adds a hidden class to the overwrite checkbox field in _form.html.erb
  - Hides the overwrite checkbox since it is only used to overwrite
the landing_page boolean on click of the "Overwrite current locked
screen" button

* Adds Admin::PagesController#create_and_overwrite and removes hidden class

* Adds landing page-related tests to admin_manages_pages_spec.rb

* Remove messy commented out code and place it in GH comment instead

* PR Review Feedback: Renames remote attr, defines class methods, updates views
  - Renames remote attribute to overwrite_landing_page
  - Updates all necessary views, methods, etc. w/ new attr
  - Defines two class methods to make code more extensible
  - Updates all necessary views, methods, etc. w/ new methods

* Remove unnecessary comments and revert changes to ternary in _form.html.erb

* Adjustments for accessibility within _form and index
  - Adds a descriptive id to <p> in _form.html.erb
  - Adds an ariadescribedby field to _form.html.erb
  - Adjusts title within index.html.erb

* Refactors landing_page-related code per PR review requests
  - Adds a landing_page_modal_controller.js that handles
and further customizes the dismiss and overwrite button, and
handles opening the modal
  - Adds a _landing_page_modal partial to extract modal-specific
html outside of the _form.html.erb partial
  - Refactors _form.html.erb to account for the _landing_page_modal
partial and the landing_page_modal_controller.js
  - Refactors the overwrite checkbox to be a hidden_field rather than
a hidden checkbox and removes existing hidden_field to accomodate it
  - Loads the @landing_page within Admin::PagesController#edit for
use by the _landing_page_modal.html.erb partial
  - Refactors Page#single_landing_page to be more readable
  - Removes useless JS from _form.html.erb

* Removes #landing_page_exists? class method since it isnt used now

* Uses the #landing_page class method within ApplicationController

* Removes pending status from test in admin_manages_pages_spec.rb

* Adds an e2e test for landing pages and adds to seeds_e2e
  - Adds a landingPage.spec.js to test landing pages
  - Adds a Page to seeds_e2e.rb for landingPage.spec.js

* Removes references to articles from e2e test and adds clickable link

* Adds another Page to seeds_e2e.rb and updates link names in test

* Adds the Current Locked Screen title to modal and opens in new link

* Renames Dismiss to Cancel and updates all necessary code

* Adjusts landingPage.spec.js

* check for existing landing page before showing modal

* Update Cypress tests and fix bug in LandingPageModalController

* Apply suggestions from code review

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>

* Orders Pages by created_at desc in /admin/pages/index.html.erb for consistency

* Targets specific edit button in landingPage.spec.js

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: rhymes <github@rhymes.dev>
2021-06-10 11:46:24 -06:00
Michael Kohl
6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* 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'
2021-05-21 14:45:37 +02:00
Michael Kohl
b7ff9aadd1
Clean up SiteConfig (#13738)
* Remove obsolete SiteConfig values

* Remove DUS

* fixup! Remove obsolete SiteConfig values

* fixup! Remove obsolete SiteConfig values

* Add DUS for removing SiteConfig values

* Fix specs

* Fix specs

* Clean up more DUS

* Update DUS

* Fix remaining spec

* Remove leftover spec

* Fix more specs

* Fix spec

* Remove deprecated spec

* Rearrange specs

* Temporarily disable specs
2021-05-18 09:38:31 +07:00
Michael Kohl
3837c3a221
Refactor handling of mandatory settings (#13553)
* Refactor handling of mandatory settings

* Add e2e test

* Rename controller
2021-04-29 09:25:16 +07:00
Ridhwana
3a4da2dd5a
RFC 50: Remove hardcoded paths and use path_helpers instead (in the specs) (#13549)
* feat: update the paths in the spec files

* feat: update hardcoded paths with path helpers

* chore: update hardcoded paths to path helpers

* chore: hardcode describe blocks

* chore: oops

* feat: update some more hardcoded to use link_to's

* fix broken tests

* chore: admin_articles path

* chore: oops remove rails helper

* feat: add starting /

* chore: more pre slashes

* chore: add pre slashes

* chore: some small typos

* fix: oops
2021-04-28 21:32:51 +02:00
Michael Kohl
610f6151e6
Split Settings::Community from SiteConfig (#13403)
* Add settings_community_contents model

* Add settings_communities model

* Update usage

* Add controller and update code

* Add e2e test

* Add data update script

* Update schema.rb

* Fix specs

* PR feedback

* Remove experience_* from Settings::Community

* Update spec

* Fix spec
2021-04-26 10:46:35 +02:00
Jacob Herrington
a5b2d109d5
Rename banned and comment_banned roles (#12270)
* 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>
2021-04-06 10:12:14 -05:00
Jacob Herrington
92217be4ed
Add admin overview page (#12726)
* Add admin overview page

* Rename admin_portals spec

* Fix admin nav bug

* Add ahoy tracking to admin overview

* Fix PR Feedback

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Make decorative element more visible

* Remove inline layout styles

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2021-03-01 18:59:05 -06:00
Ridhwana
07fcbb6f0e
Parenthesis consistency for add_role and remove_role (#12661)
* chore: use consistent code styles for the parenthesis around arguments

* Revert "chore: use consistent code styles for the parenthesis around arguments"

This reverts commit 281c899a5cff0480b182fef45b10ef69979166cb.

* chore: add consistent parenthesis
2021-02-15 20:35:25 +02:00
Ridhwana
a61f88fc16
Adds a feature flag for Data Update Scripts (#12641)
* feat: add a feature flag for data update scripts

* feat: write some tests for it

* chore: oops

* stub the data update scripts out wherever the profile admin is

* chore: remove some unneeded ones

* refactor: use call_original

* feat: add a feature flag to all the Forems (but not enable it as yet)
2021-02-10 18:22:27 +02:00
Andy Zhao
eed4df0fa4
Add sorting feature to /admin/tags (#12249)
* Use Ransack for admin/tags

* Update admin tags index to use search with Ransack

* Add feature to sort tags in /admin/tags

* Add test for viewing /admin/tags pages

* Add aria labels for sort links

* Make links a bit more accessible
2021-01-13 17:03:17 -05:00
Julianna Tetreault
ca6ba1af7d
Replace collective_noun with community_name (#11846) [deploy]
* Removes collective_noun and collective_noun_disabled from app

* Config Generalization: replaces community_qualified_name with community_name
  - Generalizes SiteConfig after the removal of collective_noun field
  - Updates copy where necessary to be readable with community_name
  - Makes the community_name SiteConfig description more explicit
  - Adds flexibility for Admins by removing appended "community"

* Adds a data_update script to remove collective_noun and collective_noun_disabled

* Removes appended community from stories_controller.rb

* Removes unnecessary quotation marks around SiteConfig.community_name.to_s

* Makes SiteConfig community_name description more explicit

* Removes topic from #email_from and replaces arg with _

* Removes argument from #email_from (facepalm)

* Reverts changes to application_mailer and notify_mailer_spec

* Removes default "Community" topic from application_mailer and makes topic optional

* Refactors #prepopulate_new_form to resolve Code Climate failures

* Refactors #email_from even further by use of a ternary operator per review suggestion

* Simplifies the data_update script used to remove collective_noun per review request

* Adds a data_update script to append community to community_name

* Updates data_update script to correctly append Community to community_name

* Removes RemoveCollectiveNounFromConfig and updates other script

* Removes superfluous false from data_update script

* Updates data_update script to be more idiomatic
2020-12-28 09:34:17 -07:00
Fernando Valverde
0ac3e83b0c
Remove resource_admin dashboards (Administrate) (#11792)
* First cleanup commit

* Email messages preview

* Tweak tests

* spec typo fix

* Remove lingering Administrate Fields & Abuse report link fix

* Add missing gemfile lock update

* Extract email_messages into its own controller & add test
2020-12-08 12:38:13 -06:00
Michael Kohl
8f5cfa2c0f
Drop profile columns from user (#10707)
* Prepare to drop profile columns from user

* Update code and factory

* Also remove unused constant

* Move validation from user to profile

* Remove Profiles::ExtractData service object

* Add more comments

* Simplify sameAs attribute generation

* Obey me machine, I am your master

* Fix condition order in guard clause

* Temporarily disable callback

* Fix specs

* Reduce usage of Profile#refresh_attributes!

* Remove leftover comment

* Handle social media links differently

* More spec fixes

* Fix specs for admin profile fields controller

* Fix specs after merge

* Fix remaining specs

* Update user show request spec

* Add comment for follow_hiring_tag

* Only save profile when user is valid

* Fix seeds.rb for profile fields

* Switch from before_save to after_save

* Undo unrelated formattin change

* Update spec/fixtures/files/profile_fields.csv

Co-authored-by: Molly Struve <mollylbs@gmail.com>

* Remove data update script and spec

* Fix spec

* Fix typo in comment

* Fix typo in comment

* Move article resave logic to service object

* Move profile field creation to before(:suite)

* Refactor error handling in Profiles::Update

* Fix Profiles::Update specs and refactor

* Temporarily disable spec

* Add ProfileValidator

* Clean up

* Move DB ready check into app/lib

* Refresh attributes after importing from CSV

* Fix specs

* Remove unused file

* A girl has no name. A profile neither.

* Fix specs

* Add responds_to? check

* Spec fix

* Add name to user fields in profile settings page

Co-authored-by: Molly Struve <mollylbs@gmail.com>
2020-12-03 08:14:38 +07:00
Fernando Valverde
c740b4e6dd
Adds ability for admins to create new tags via /admin/tags (#11240)
* Adds ability for admins to create new tags via /admin/tags

* Merge branch 'master' of github.com:forem/forem into fdoxyz/admin-new-tags-11026

* Fix rubocop pre-hook

* UI Tweaks

* replaces show with edit action & other minor changes

* Reverse unrelated changes

* Removed more unrelated edits

* Fix specs

* Fix moderator link
2020-12-02 08:12:57 -06:00
Arit Amana
845e00797b
[EOY 2020] Replace "ban" with "suspend" in Admin (#11581)
* Implement changes

* display "Suspended" if user role.name is banned

* Correct equality symbol

Co-authored-by: Michael Kohl <me@citizen428.net>

Co-authored-by: Michael Kohl <me@citizen428.net>
2020-11-25 09:15:07 -05:00
Jacob Herrington
94fe355dae
Add system spec for profile fields (#11398)
* Add system spec for profile fields

* Use FeatureFlag wrapper over Flipper
2020-11-13 14:51:42 -06:00
Jacob Herrington
de5122cb52
Use Rails path helpers in admin system specs (#11399) 2020-11-13 10:45:57 -06:00
rhymes
33dccc7997
Move badges_area template in proper place and refactor the partial (#11400)
* Move badges_area template in proper place and refactor the partial

* Fix badge show routing
2020-11-13 14:23:50 +01:00
Julianna Tetreault
aa7ef577cb
Adds a Default Color Hex Value to the Admin Tags Color Field (#11105) [deploy]
* Adds a default color hex value to the /admin/tags/show color picker

* Rebased against color-picker changes and adds default color to edit.html.erb

* Adds a system spec for admin/tags and adjusts the filename for admin_creates_new_page_spec

* Uses .blank? in place of .nil? in admin/tags/show.html.erb

* Refactors test in admin_updates_tag_spec.rb
2020-11-02 12:50:03 -07:00
Alex
cb6781740f
[deploy] Update site config defaults (#11172)
* Update site config defaultss with specs

* Add missing .freeze

* Fix specs
2020-10-30 13:40:09 -04:00
rhymes
caad342033
Small Rubocop fixes (#11182) 2020-10-30 14:45:55 +01:00
Julianna Tetreault
6f4e600a4e
Refactor Admin Events Index (#11103) [deploy]
* Adds new and edit views for events and removes them from the index view

* Fixes formatting issues in /admin/pages/index.html.erb

* Refactors /admin/events partial, new, and edit forms

* Updates admin_events routes to include all routes except destroy

* Refactors Admin::EventsController and adds #new and #edit actions

* specs: Adjusts admin_creates_new_event_spec to work with /admin/event changes

* Refactors the Admin::EventsController, routes, and events index even further
  - Adds back placeholder text in Events form
  - Removes unnecessary code from controller
  - Reverts changes to routes
  - Adjusts event_cover_image size on index.html.erb

* specs: Adds tests around creating and updating events to events_spec

* Adds pagination to Admin::EventsController #index to cap events at 20 per page

* Removes .all from Admin::EventsController and adds a line to index.html.erb

* Uses crayons classes for _event_form.html.erb
2020-10-29 10:11:15 -06:00
Alex
94cd9e246f
[deploy] Add default for main_social_image (#11126)
* Add default for main_social_image

* Fix image URL and add spec

* Fix spec

* Move image_url helper into image module

* Fix typo in comment

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>

* Change URL helper logic

* Try something else

* Use ApplicationConfig

* Refactor

* Try again

* Try again with another approach

* Add specs for URL.local_image

Co-authored-by: Vaidehi Joshi <vaidehi.sj@gmail.com>
2020-10-29 10:07:14 -04:00
Jacob Herrington
8f5954aeb8
[deploy] Improve error messages and validation for admin pages (#11141)
* Improve error messages and validation for pages

This could probably be cleaner, but I wanted to avoid changing behavior,
so there is a bit of redundancy.

In this commit, I also had to convert an if statement to a case
statement for Rubocop.

* Add system spec for editing pages

* Use errors_as_sentence
2020-10-28 13:54:38 -05:00
Jacob Herrington
173e79bdfa
Add a button to delete pages (#10971) 2020-10-20 17:49:17 -05:00
Ridhwana
6a7b78e4a0
Allow admins to turn "some" hardcoded pages into a "Page" (#10877)
* feat: allow a page to override the code_of_conduct, terms and privacy page

* feat: let privacy policy also use a partial for its contents like coc and terms

* feat: show the defaults or the pages

* specs: add tests for the overrides

* feat: update some styles and make use crayons buttons

* fix: update order of test items

* spec: fix

* reactor: move this whole section in the if

* feat: updates

* fix: code climate + travis

* more codeeclimate
2020-10-16 12:37:06 -04:00
Vaidehi Joshi
c4efee10bf
Do not require meta_keywords to be set (#10721)
* Remove extra character from meta_keywords in /listings/index.html.erb

* Remove meta_keywords from MANDATORY_CONFIGS

* Add and use meta_keywords_tag helper

* Use modern tag syntax instead of deprecated syntax

* Add and use meta_keywords_default helper

* Add and use meta_keywords_article helper

* Remove * from meta_keywords_field.label

* Update meta_keyword specs to account for no keywords being set
2020-10-08 10:51:25 -04:00
Vaidehi Joshi
f83062a9dd
Remove community_action from SiteConfig (#10678) 2020-10-06 15:46:04 -04:00
Anna Buianova
aa40d5ffdb
Improve setup not completed notification (#10411) 2020-09-22 10:26:50 +07:00
Anna Buianova
fec947ce45
More detailed notification when setup is not completed (#10375) 2020-09-18 09:24:49 -04:00
ludwiczakpawel
8ec4044f3e
[deploy] Adding Crayons to Admin (#10015)
* layout

* user

* config

* header

* badges, badge_achievements, layout

* broadcasts

* chat channels

* comments.. not much really

* Events

* growth

* listings

* mod actions

* mods

* orgs

* pages

* permissions

* podcasts

* reactions

* profile fields

* reports

* response templates

* tools

* users

* Secrets

* webhooks

* welcome threads

* .

* internal

* css fix

* .

* main element elsewhere

* scope

* bring back some of the old styling

* .

* .

* .

* notice

* Revert schema.db

* add alert

* little fixes

* profile fields

* Update schema.rb

* closing span

* another span

* Fixed broken admin specs.

Co-authored-by: Nick Taylor <nick@dev.to>
2020-08-31 10:29:06 -04:00
Arit Amana
03a89c4a4a
[Admin Tooling] Styling improvements to Chat Channels page (#9926)
* Styling changes to Chat Channel page

* Update text to be clearer

* Make chnages from PR review

* Fix failing spec

* Fix spec
2020-08-21 15:35:13 -04:00
Arit Amana
d6465750ba
[deploy] [Admin Tooling] Allow admins delete empty Connect Channels (#9873)
* Configure Delete Channel functionality

* Add specs

* Remove unnecessary variable

* Address PR review comments

* Revert optimization of any_admin? method

* Implement @any_admin? properly

* Fix markup to fix the styling

Co-authored-by: rhymes <rhymes@hey.com>
2020-08-20 14:55:48 +02:00
Julianna Tetreault
c18b0f1ba1
Manage Badges in /admin/badges (#9721) [deploy]
* Add CRUD actions for badge management to Internal::Badges::Controller

* Update sytling of badges index view in index.html.erb
  -Uses a table to display all badges
  -Links to the badge edit page from the badge title
  -Displays a badges slug, title, and badge_image
  -Adds an Award Badge button to the index view

* Adds an edit view, edit.html.erb, for badges
  -Gives the ability to edit a badge title and/or slug
  -Adds an Update Badge button to the left of the view
  -Adds a Back to All Badges button to the right of the view
  -Displays the badge image in the edit form

* Adjusts the path names in #award_badges in Internal::Badges::Controller

* Adds CRUD actions to the Internal::Badges::Controller and needed routes

* Add a description field to the edit.html.erb for badge management

* Add #award to Internal::Badges::Controller with matching view and routes
  -Adds an #award method that sets @badge for #award_badges
  -Adds an award.html.erb view for awarding badges
  -Adds an award path for awarding badges
  -Removes unnecessary code from controller, routes, and views

* Adds image upload functionality to the edit view for badges

* Ensure that usernames are downcased when awarding badges
  -Chains downcase to usernames in #award_badges in
   Internal::Badges::Controller

* Move badge-related views from old Internal folder to the correct Admin folder

Change routes and paths from /internal to /admin

* Refactor badge_params in Admin::Badges::Controller

* Add additional tests around awarding and updating badges in /admin/badge_achievements

* Add a create view to /admin/badges
  -Adds new and create actions to Admin::Badges::Controller
  -Adds a create view for creating badges at new.html.erb
  -Adds a Create Badge button to the index view
  -Moves the Award Badges button to the bottom of the index view

* Add a test around creating badges and clean up existing specs in badges_spec.rb

Adjust path in admin_awards_badges_spec.rb to be correct path

* Adjust routes from /badges/award_badges to /badges/badge_achievements/award_badges

Update paths in admin/badge-related specs

* Adjust paths in badges_spec.rb to be admin_badge_achievements_award_badges_path

* Adjust button styling for Award Badge

* Adjust paths back to /admin/badges in badges_spec.rb

* Add clarification around usernames when awarding badges

* Mark test in black_box_spec.rb as pending due to Travis failure

* Change wording used around usernames and @ symbols in award.html.erb
2020-08-13 08:54:51 -06:00