Remove mascot footer image (#13642)

* Remove footer mascot image

* Move remaining mascot settings back to SiteConfig

* Add data update script

* Update usages

* Fix path

* Remove dead route

* Update tests

* Fix view and spec

* Fix e2e test

* Fix DUS
This commit is contained in:
Michael Kohl 2021-05-11 18:55:18 +07:00 committed by GitHub
parent ce46ea2378
commit 111b7316d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 86 additions and 274 deletions

View file

@ -1,34 +0,0 @@
module Admin
module Settings
class MascotsController < Admin::ApplicationController
def create
errors = upsert_config(settings_params)
if errors.none?
Audit::Logger.log(:internal, current_user, params.dup)
redirect_to admin_config_path, notice: "Site configuration was successfully updated."
else
redirect_to admin_config_path, alert: "😭 #{errors.to_sentence}"
end
end
def settings_params
params
.require(:settings_mascot)
.permit(*::Settings::Mascot.keys)
end
def upsert_config(configs)
errors = []
configs.each do |key, value|
::Settings::Mascot.public_send("#{key}=", value) if value.present?
rescue ActiveRecord::RecordInvalid => e
errors << e.message
next
end
errors
end
end
end
end

View file

@ -57,10 +57,10 @@ class ChatChannelsController < ApplicationController
flash[:error] = chat_channel.errors.full_messages.to_sentence
else
if chat_channel_params[:discoverable].to_i.zero?
ChatChannelMembership.create(user_id: Settings::Mascot.mascot_user_id, chat_channel_id: chat_channel.id,
ChatChannelMembership.create(user_id: SiteConfig.mascot_user_id, chat_channel_id: chat_channel.id,
role: "member", status: "active")
else
ChatChannelMembership.find_by(user_id: Settings::Mascot.mascot_user_id)&.destroy
ChatChannelMembership.find_by(user_id: SiteConfig.mascot_user_id)&.destroy
end
flash[:settings_notice] = "Channel settings updated."
end
@ -76,10 +76,10 @@ class ChatChannelsController < ApplicationController
message: "Channel settings updation failed. Try again later." }, success: :bad_request
else
if chat_channel_params[:discoverable]
ChatChannelMembership.create(user_id: Settings::Mascot.mascot_user_id, chat_channel_id: @chat_channel.id,
ChatChannelMembership.create(user_id: SiteConfig.mascot_user_id, chat_channel_id: @chat_channel.id,
role: "member", status: "active")
else
ChatChannelMembership.find_by(user_id: Settings::Mascot.mascot_user_id)&.destroy
ChatChannelMembership.find_by(user_id: SiteConfig.mascot_user_id)&.destroy
end
render json: { success: true, message: "Channel settings updated.", data: {} }, success: :ok
end

View file

@ -110,7 +110,7 @@ class CommentsController < ApplicationController
response_template = ResponseTemplate.find(params[:response_template][:id])
authorize response_template, :moderator_create?
moderator = User.find(Settings::Mascot.mascot_user_id)
moderator = User.find(SiteConfig.mascot_user_id)
@comment = Comment.new(permitted_attributes(Comment))
@comment.user_id = moderator.id
@comment.body_markdown = response_template.content

View file

@ -68,7 +68,7 @@ class SearchController < ApplicationController
def chat_channels
user_ids =
if chat_channel_params[:user_id].present?
[current_user.id, Settings::Mascot.mascot_user_id, chat_channel_params[:user_id]].reject(&:blank?)
[current_user.id, SiteConfig.mascot_user_id, chat_channel_params[:user_id]].reject(&:blank?)
else
[current_user.id]
end

View file

@ -1,32 +0,0 @@
module Constants
module Settings
module Mascot
DETAILS = {
footer_image_url: {
description: "Special cute mascot image used in the footer.",
placeholder: ::Constants::SiteConfig::IMAGE_PLACEHOLDER
},
footer_image_width: {
description: "The footer mascot width will resized to this value, defaults to 52",
placeholder: ""
},
footer_image_height: {
description: "The footer mascot height will be resized to this value, defaults to 120",
placeholder: ""
},
image_description: {
description: "Used as the alt text for the mascot image",
placeholder: ""
},
image_url: {
description: "Used as the mascot image.",
placeholder: ::Constants::SiteConfig::IMAGE_PLACEHOLDER
},
mascot_user_id: {
description: "User ID of the Mascot account",
placeholder: "1"
}
}.freeze
end
end
end

View file

@ -70,6 +70,14 @@ module Constants
description: "Community Moderators Newsletter ID",
placeholder: ""
},
mascot_image_url: {
description: "Used as the mascot image.",
placeholder: ::Constants::SiteConfig::IMAGE_PLACEHOLDER
},
mascot_user_id: {
description: "User ID of the Mascot account",
placeholder: "1"
},
meta_keywords: {
description: "",
placeholder: "List of valid keywords: comma separated, letters only e.g. engineering, development"

View file

@ -178,7 +178,7 @@ class Article < ApplicationRecord
.where(user_id: User.with_role(:super_admin)
.union(User.with_role(:admin))
.union(id: [Settings::Community.staff_user_id,
Settings::Mascot.mascot_user_id].compact)
SiteConfig.mascot_user_id].compact)
.select(:id)).order(published_at: :desc).tagged_with(tag_name)
}
@ -788,7 +788,7 @@ class Article < ApplicationRecord
return unless SiteConfig.spam_trigger_terms.any? { |term| Regexp.new(term.downcase).match?(title.downcase) }
Reaction.create(
user_id: Settings::Mascot.mascot_user_id,
user_id: SiteConfig.mascot_user_id,
reactable_id: id,
reactable_type: "Article",
category: "vomit",
@ -798,7 +798,7 @@ class Article < ApplicationRecord
user.add_role(:suspended)
Note.create(
author_id: Settings::Mascot.mascot_user_id,
author_id: SiteConfig.mascot_user_id,
noteable_id: user_id,
noteable_type: "User",
reason: "automatic_suspend",

View file

@ -274,7 +274,7 @@ class Comment < ApplicationRecord
user.registered_at > 5.days.ago
Reaction.create(
user_id: Settings::Mascot.mascot_user_id,
user_id: SiteConfig.mascot_user_id,
reactable_id: id,
reactable_type: "Comment",
category: "vomit",
@ -284,7 +284,7 @@ class Comment < ApplicationRecord
user.add_role(:suspended)
Note.create(
author_id: Settings::Mascot.mascot_user_id,
author_id: SiteConfig.mascot_user_id,
noteable_id: user_id,
noteable_type: "User",
reason: "automatic_suspend",

View file

@ -130,7 +130,7 @@ class Reaction < ApplicationRecord
end
def negative_reaction_from_untrusted_user?
return if user&.any_admin? || user&.id == Settings::Mascot.mascot_user_id
return if user&.any_admin? || user&.id == SiteConfig.mascot_user_id
negative? && !user.trusted
end

View file

@ -6,10 +6,6 @@ module Settings
# the cache, or call Settings::Mascot.clear_cache
cache_prefix { "v1" }
field :footer_image_height, type: :integer, default: 120
field :footer_image_url, type: :string, validates: { url: true }
field :footer_image_width, type: :integer, default: 52
field :image_description, type: :string, default: "The community mascot"
field :image_url,
type: :string,
default: proc { URL.local_image("mascot.png") },

View file

@ -103,10 +103,6 @@ class SiteConfig < RailsSettings::Base
type: :string,
default: proc { URL.local_image("mascot.png") },
validates: { url: true }
field :mascot_image_description, type: :string, default: "The community mascot"
field :mascot_footer_image_url, type: :string, validates: { url: true }
field :mascot_footer_image_width, type: :integer, default: 52
field :mascot_footer_image_height, type: :integer, default: 120
# Meta keywords
field :meta_keywords, type: :hash, default: {

View file

@ -310,7 +310,7 @@ class User < ApplicationRecord
end
def self.mascot_account
find_by(id: Settings::Mascot.mascot_user_id)
find_by(id: SiteConfig.mascot_user_id)
end
def tag_line

View file

@ -18,7 +18,7 @@ module Authentication
}
if Rails.env.test?
user_data[:profile_image] = Settings::Mascot.image_url
user_data[:profile_image] = SiteConfig.mascot_image_url
else
user_data[:remote_profile_image_url] = Users::ProfileImageGenerator.call
end

View file

@ -4,7 +4,7 @@ module Users
email: "mascot@forem.com",
username: "mascot",
name: "Mascot",
profile_image: Settings::Mascot.image_url,
profile_image: SiteConfig.mascot_image_url,
confirmed_at: Time.current,
registered_at: Time.current,
password: SecureRandom.hex
@ -15,10 +15,10 @@ module Users
end
def call
raise "Mascot already set" if Settings::Mascot.mascot_user_id
raise "Mascot already set" if SiteConfig.mascot_user_id
mascot = User.create!(mascot_params)
Settings::Mascot.mascot_user_id = mascot.id
SiteConfig.mascot_user_id = mascot.id
end
def mascot_params

View file

@ -739,7 +739,7 @@
</div>
<% end %>
<%= form_for(Settings::Mascot.new, url: admin_settings_mascots_path, html: { data: { testid: "mascotSectionForm" } }) do |f| %>
<%= form_for(SiteConfig.new, url: admin_config_path, html: { data: { testid: "mascotSectionForm" } }) do |f| %>
<div class="card mt-3">
<%= render partial: "admin/shared/card_header",
locals: {
@ -751,67 +751,29 @@
<div id="mascotBodyContainer" class="card-body collapse hide" aria-labelledby="mascotBodyContainer">
<fieldset class="grid gap-4">
<div class="crayons-field">
<%= admin_config_label :mascot_user_id, "Mascot user ID", model: Settings::Mascot %>
<%= admin_config_description Constants::Settings::Mascot::DETAILS[:mascot_user_id][:description] %>
<%= admin_config_label :mascot_user_id, "Mascot user ID" %>
<%= admin_config_description Constants::SiteConfig::DETAILS[:mascot_user_id][:description] %>
<%= f.text_field :mascot_user_id,
class: "crayons-textfield",
value: Settings::Mascot.mascot_user_id,
value: SiteConfig.mascot_user_id,
min: 1,
placeholder: Constants::Settings::Mascot::DETAILS[:mascot_user_id][:placeholder] %>
placeholder: Constants::SiteConfig::DETAILS[:mascot_user_id][:placeholder] %>
</div>
<div class="crayons-field">
<%= admin_config_label :image_url, "Mascot Image URL", model: Settings::Mascot %>
<%= admin_config_description Constants::Settings::Mascot::DETAILS[:image_url][:description] %>
<%= f.text_field :image_url,
<%= admin_config_label :mascot_image_url, "Mascot Image URL" %>
<%= admin_config_description Constants::SiteConfig::DETAILS[:mascot_image_url][:description] %>
<%= f.text_field :mascot_image_url,
class: "crayons-textfield",
value: Settings::Mascot.image_url,
placeholder: Constants::Settings::Mascot::DETAILS[:image_url][:placeholder] %>
value: SiteConfig.mascot_image_url,
placeholder: Constants::SiteConfig::DETAILS[:mascot_image_url][:placeholder] %>
<div class="col-12">
<img alt="<%= Settings::Mascot.image_description %>" class="img-fluid" src="<%= Settings::Mascot.image_url %>" />
<img alt="Mascot image" class="img-fluid" src="<%= SiteConfig.mascot_image_url %>" />
</div>
</div>
<div class="crayons-field">
<%= admin_config_label :footer_image_url, model: Settings::Mascot %>
<%= admin_config_description Constants::Settings::Mascot::DETAILS[:footer_image_url][:description] %>
<%= f.text_field :footer_image_url,
class: "crayons-textfield",
value: Settings::Mascot.footer_image_url,
placeholder: Constants::Settings::Mascot::DETAILS[:footer_image_url][:placeholder] %>
<div class="col-12">
<img alt="<%= Settings::Mascot.image_description %>" class="img-fluid" src="<%= Settings::Mascot.footer_image_url %>" />
</div>
</div>
<div class="crayons-field">
<%= admin_config_label :footer_image_width, model: Settings::Mascot %>
<%= admin_config_description Constants::Settings::Mascot::DETAILS[:footer_image_width][:description] %>
<%= f.text_field :footer_image_width,
class: "form-control",
value: Settings::Mascot.footer_image_width %>
</div>
<div class="crayons-field">
<%= admin_config_label :footer_image_height, model: Settings::Mascot %>
<%= admin_config_description Constants::Settings::Mascot::DETAILS[:footer_image_height][:description] %>
<%= f.text_field :footer_image_height,
class: "form-control",
value: Settings::Mascot.footer_image_height %>
</div>
<div class="crayons-field">
<%= admin_config_label :image_description, model: Settings::Mascot %>
<%= admin_config_description Constants::Settings::Mascot::DETAILS[:image_description][:description] %>
<%= f.text_field :image_description,
class: "form-control",
value: Settings::Mascot.image_description %>
</div>
<%= render "form_submission", f: f %>
<%= render "form_submission", f: f %>
</fieldset>
</div>
</div>

View file

@ -31,7 +31,7 @@
data-reaction-url-value="<%= admin_reaction_path(reaction.id) %>">
<span>
🤢 <a href="<%= reaction.user.path %>" target="_blank" rel="noopener">@<%= reaction.user.username %></a>
<% if reaction.user_id == Settings::Mascot.mascot_user_id %>
<% if reaction.user_id == SiteConfig.mascot_user_id %>
<strong>(auto-generated)</strong>
<% end %>
</span>

View file

@ -1,6 +1,6 @@
<% if comment.deleted %>
<span class="shrink-0 crayons-avatar <% if comment.depth == 0 %>m:crayons-avatar--l mt-4 m:mt-3<% else %>mt-4<% end %>">
<%= image_tag(Images::Optimizer.call(Settings::Mascot.image_url, width: 32, height: 32, crop: "imagga_scale"), class: "crayons-avatar__image overflow-hidden", alt: "Sloan, the sloth mascot", loading: "lazy") %>
<%= image_tag(Images::Optimizer.call(SiteConfig.mascot_image_url, width: 32, height: 32, crop: "imagga_scale"), class: "crayons-avatar__image overflow-hidden", alt: "Sloan, the sloth mascot", loading: "lazy") %>
</span>
<% else %>
<a href="<%= URL.user(comment.user) %>" class="shrink-0 crayons-avatar <% if comment.depth == 0 %>m:crayons-avatar--l mt-4 m:mt-3<% else %>mt-4<% end %>">

View file

@ -14,7 +14,7 @@
<% if decorated_comment.low_quality %>
<div class="crayons-notice crayons-notice--warning low-quality-comment-marker">
<%= image_tag(Images::Optimizer.call(Settings::Mascot.image_url, width: 50, height: 50, crop: "imagga_scale"), class: "sloan", alt: "Sloan, the sloth mascot", loading: "lazy") %>
<%= image_tag(Images::Optimizer.call(SiteConfig.mascot_image_url, width: 50, height: 50, crop: "imagga_scale"), class: "sloan", alt: "Sloan, the sloth mascot", loading: "lazy") %>
Comment marked as low quality/non-constructive by the community. <a href="/code-of-conduct">View Code of Conduct</a>
</div>
<% end %>

View file

@ -55,9 +55,9 @@
<% else %>
<div class="p-6 m:p-9 crayons-card crayons-card--secondary align-center fs-l h-100 flex items-center justify-center flex-1">
<div>
<% if Settings::Mascot.image_url.present? %>
<% image_url = Images::Optimizer.call(Settings::Mascot.image_url, width: 300, crop: "imagga_scale") %>
<%= image_tag(image_url, class: "sloan mb-7", alt: Settings::Mascot.image_description.to_s) %>
<% if SiteConfig.mascot_image_url.present? %>
<% image_url = Images::Optimizer.call(SiteConfig.mascot_image_url, width: 300, crop: "imagga_scale") %>
<%= image_tag(image_url, class: "sloan mb-7", alt: "Mascot image") %>
<% end %>
<p class="mb-6">This is where you can manage your posts, but you haven't written anything yet.</p>
<p><a href="/new" class="crayons-btn crayons-btn--l">Write your first post now</a></p>

View file

@ -25,13 +25,5 @@
<div><a href="https://www.forem.com" target="_blank" rel="noopener" class="inline-block mt-4"><%= inline_svg_tag("logo-forem.svg", aria: true, class: "crayons-icon crayons-icon--default", title: "Forem logo") %></a></div>
</div>
</div>
<% if Settings::Mascot.footer_image_url.present? %>
<%= image_tag(Images::Optimizer.call(Settings::Mascot.footer_image_url, width: 100),
class: "crayons-footer__mascot",
alt: Settings::Mascot.image_description,
width: Settings::Mascot.footer_image_width,
height: Settings::Mascot.footer_image_height,
loading: "lazy") %>
<% end %>
</footer>
<div id="snack-zone"></div>

View file

@ -19,7 +19,6 @@ namespace :admin do
resources :campaigns, only: [:create]
resources :communities, only: [:create]
resources :mandatory_settings, only: [:create]
resources :mascots, only: [:create]
resources :rate_limits, only: [:create]
resources :user_experiences, only: [:create]
end

View file

@ -16,9 +16,9 @@ describe('Mascot Section', () => {
cy.get('@mascotSectionForm').findByText('Mascot').click();
cy.get('@mascotSectionForm')
.get('#settings_mascot_image_url')
.findByLabelText('Mascot Image URL')
.clear()
.type('example.com/image.png');
.type('notanimage');
cy.get('@mascotSectionForm')
.findByPlaceholderText('Confirmation text')
@ -33,7 +33,7 @@ describe('Mascot Section', () => {
cy.url().should('contains', '/admin/customization/config');
cy.findByText(
'😭 Validation failed: Image url is not a valid URL',
'😭 Validation failed: Mascot image url is not a valid URL',
).should('be.visible');
});
});
@ -45,7 +45,7 @@ describe('Mascot Section', () => {
cy.get('@mascotSectionForm').findByText('Mascot').click();
cy.get('@mascotSectionForm')
.get('#settings_mascot_image_url')
.findByLabelText('Mascot Image URL')
.clear()
.type('https://example.com/image.png');
@ -66,8 +66,8 @@ describe('Mascot Section', () => {
);
// Page reloaded so need to get a new reference to the form.
cy.get('#new_settings_mascot').as('mascotSectionForm');
cy.get('#settings_mascot_image_url').should(
cy.findByTestId('mascotSectionForm').as('mascotSectionForm');
cy.findByLabelText('Mascot Image URL').should(
'have.value',
'https://example.com/image.png',
);

View file

@ -1,20 +0,0 @@
module DataUpdateScripts
class MoveMascotSettings
SETTINGS = %w[
footer_image_height
footer_image_url
footer_image_width
image_description
image_url
].freeze
def run
SETTINGS.each do |setting|
if (value = SiteConfig.public_send("mascot_#{setting}"))
Settings::Mascot.public_send("#{setting}=", value)
end
end
Settings::Mascot.mascot_user_id = SiteConfig.mascot_user_id
end
end
end

View file

@ -0,0 +1,17 @@
module DataUpdateScripts
class MoveMascotSettingsBacktoSiteConfig
def run
return unless Database.table_available?("settings_mascots")
# Remove obsolete data update script
DataUpdateScript.delete_by(file_name: "20210420050256_move_mascot_settings")
# Migrate back explicitly set values
mascot_image_url = Settings::Mascot.image_url
SiteConfig.mascot_image_url = mascot_image_url if mascot_image_url
mascot_user_id = Settings::Mascot.mascot_user_id
SiteConfig.mascot_user_id = mascot_user_id if mascot_user_id
end
end
end

View file

@ -1,28 +0,0 @@
require "rails_helper"
require Rails.root.join(
"lib/data_update_scripts/20210420050256_move_mascot_settings.rb",
)
describe DataUpdateScripts::MoveMascotSettings do
before do
allow(SiteConfig).to receive(:mascot_footer_image_url)
.and_return("https://example.com/mascot.png")
end
it "moves renamed settings" do
allow(SiteConfig).to receive(:mascot_image_description).and_return("Bla")
expect do
described_class.new.run
end
.to change(Settings::Mascot, :image_description)
.and change(Settings::Mascot, :footer_image_url)
end
it "moves the non-renamed./spec/lib/data_update_scripts/move_mascot_settings_spec.rb setting" do
allow(SiteConfig).to receive(:mascot_user_id).and_return(42)
expect do
described_class.new.run
end.to change(Settings::Mascot, :mascot_user_id).to(42)
end
end

View file

@ -55,7 +55,7 @@ RSpec.describe Article, type: :model do
describe "::admin_published_with" do
it "includes mascot-published articles" do
allow(Settings::Mascot).to receive(:mascot_user_id).and_return(3)
allow(SiteConfig).to receive(:mascot_user_id).and_return(3)
user = create(:user, id: 3)
create(:article, user: user, tags: "challenge")
expect(described_class.admin_published_with("challenge").count).to eq(1)
@ -989,7 +989,7 @@ RSpec.describe Article, type: :model do
describe "spam" do
before do
allow(Settings::Mascot).to receive(:mascot_user_id).and_return(user.id)
allow(SiteConfig).to receive(:mascot_user_id).and_return(user.id)
allow(SiteConfig).to receive(:spam_trigger_terms).and_return(
["yahoomagoo gogo", "testtestetest", "magoo.+magee"],
)

View file

@ -414,7 +414,7 @@ RSpec.describe Comment, type: :model do
describe "spam" do
before do
allow(Settings::Mascot).to receive(:mascot_user_id).and_return(user.id)
allow(SiteConfig).to receive(:mascot_user_id).and_return(user.id)
allow(SiteConfig).to receive(:spam_trigger_terms).and_return(["yahoomagoo gogo", "anothertestterm"])
end

View file

@ -44,13 +44,13 @@ RSpec.describe Reaction, type: :model do
end
it "does not allow vomit reaction for users without trusted role" do
allow(Settings::Mascot).to receive(:mascot_user_id).and_return(user.id + 1)
allow(SiteConfig).to receive(:mascot_user_id).and_return(user.id + 1)
reaction.category = "vomit"
expect(reaction).not_to be_valid
end
it "does not allow thumbsdown reaction for users without trusted role" do
allow(Settings::Mascot).to receive(:mascot_user_id).and_return(user.id + 1)
allow(SiteConfig).to receive(:mascot_user_id).and_return(user.id + 1)
reaction.category = "thumbsdown"
expect(reaction).not_to be_valid
end

View file

@ -5,7 +5,7 @@ RSpec.describe SiteConfig, type: :model do
describe "validating URLs" do
let(:url_fields) do
%w[
main_social_image logo_png mascot_image_url mascot_footer_image_url onboarding_background_image
main_social_image logo_png mascot_image_url onboarding_background_image
]
end

View file

@ -815,7 +815,7 @@ RSpec.describe User, type: :model do
end
it "returns the user if the account exists" do
allow(Settings::Mascot).to receive(:mascot_user_id).and_return(user.id)
allow(SiteConfig).to receive(:mascot_user_id).and_return(user.id)
expect(described_class.mascot_account).to eq(user)
end

View file

@ -406,66 +406,22 @@ RSpec.describe "/admin/customization/config", type: :request do
describe "Mascot" do
it "updates the mascot_user_id" do
expected_mascot_user_id = 2
post admin_settings_mascots_path, params: {
settings_mascot: { mascot_user_id: expected_mascot_user_id },
post admin_config_path, params: {
site_config: { mascot_user_id: expected_mascot_user_id },
confirmation: confirmation_message
}
expect(Settings::Mascot.mascot_user_id).to eq(expected_mascot_user_id)
expect(SiteConfig.mascot_user_id).to eq(expected_mascot_user_id)
end
it "updates image_url" do
expected_default_image_url = Settings::Mascot.get_default(:image_url)
expected_default_image_url = SiteConfig.get_default(:mascot_image_url)
expected_image_url = "https://dummyimage.com/300x300.png"
expect do
post admin_settings_mascots_path, params: {
settings_mascot: { image_url: expected_image_url },
post admin_config_path, params: {
site_config: { mascot_image_url: expected_image_url },
confirmation: confirmation_message
}
end.to change(Settings::Mascot, :image_url).from(expected_default_image_url).to(expected_image_url)
end
it "updates footer_image_url" do
expected_image_url = "https://dummyimage.com/300x300.png"
post admin_settings_mascots_path, params: {
settings_mascot: { footer_image_url: expected_image_url },
confirmation: confirmation_message
}
expect(Settings::Mascot.footer_image_url).to eq(expected_image_url)
end
it "updates the footer_image_width" do
expected_default_footer_image_width = Settings::Mascot.get_default(:footer_image_width)
expected_footer_image_width = 1002
expect(Settings::Mascot.footer_image_width).to eq(expected_default_footer_image_width)
post admin_settings_mascots_path, params: {
settings_mascot: { footer_image_width: expected_footer_image_width },
confirmation: confirmation_message
}
expect(Settings::Mascot.footer_image_width).to eq(expected_footer_image_width)
end
it "updates the footer_image_height" do
expected_default_footer_image_height = Settings::Mascot.get_default(:footer_image_height)
expected_footer_image_height = 3002
expect(Settings::Mascot.footer_image_height).to eq(expected_default_footer_image_height)
post admin_settings_mascots_path, params: {
settings_mascot: { footer_image_height: expected_footer_image_height },
confirmation: confirmation_message
}
expect(Settings::Mascot.footer_image_height).to eq(expected_footer_image_height)
end
it "updates image_description" do
description = "Hey hey #{rand(100)}"
post admin_settings_mascots_path, params: {
settings_mascot: { image_description: description },
confirmation: confirmation_message
}
expect(Settings::Mascot.image_description).to eq(description)
end.to change(SiteConfig, :mascot_image_url).from(expected_default_image_url).to(expected_image_url)
end
end

View file

@ -161,7 +161,7 @@ RSpec.describe "CommentsCreate", type: :request do
end
def reply_and_mention_comment_author_as_moderator(comment)
allow(Settings::Mascot).to receive(:mascot_user_id)
allow(SiteConfig).to receive(:mascot_user_id)
.and_return(moderator_replier.id)
sign_in moderator_replier

View file

@ -370,14 +370,14 @@ RSpec.describe "Registrations", type: :request do
end
it "creates mascot user" do
expect(Settings::Mascot.mascot_user_id).to be_nil
expect(SiteConfig.mascot_user_id).to be_nil
post "/users", params:
{ user: { name: "test #{rand(10)}",
username: "haha_#{rand(10)}",
email: "yoooo#{rand(100)}@yo.co",
password: "PaSSw0rd_yo000",
password_confirmation: "PaSSw0rd_yo000" } }
expect(Settings::Mascot.mascot_user_id).to eq User.last.id
expect(SiteConfig.mascot_user_id).to eq User.last.id
mascot_account = User.mascot_account
expect(mascot_account.username).to eq Users::CreateMascotAccount::MASCOT_PARAMS[:username]

View file

@ -6,7 +6,7 @@ RSpec.describe Users::CreateMascotAccount, type: :service do
end
context "when a mascot user doesn't exist" do
before { allow(Settings::Mascot).to receive(:mascot_user_id).and_return(nil) }
before { allow(SiteConfig).to receive(:mascot_user_id).and_return(nil) }
it "creates a mascot account" do
expect do
@ -21,7 +21,7 @@ RSpec.describe Users::CreateMascotAccount, type: :service do
context "when a mascot user already exists" do
before do
allow(Settings::Mascot).to receive(:mascot_user_id).and_return(2)
allow(SiteConfig).to receive(:mascot_user_id).and_return(2)
allow(User).to receive(:create)
end

View file

@ -7,7 +7,7 @@ RSpec.describe "dashboards/show.html.erb", type: :view do
stub_template "dashboards/_actions.html.erb" => "stubbed content"
allow(Images::Optimizer).to receive(:imgproxy_enabled?).and_return(true)
allow(Settings::Mascot).to receive(:image_url).and_return("https://i.imgur.com/fKYKgo4.png")
allow(SiteConfig).to receive(:mascot_image_url).and_return("https://i.imgur.com/fKYKgo4.png")
end
context "when using Imgproxy" do