[15 Min. Fix] Update Default bg_color and text_color Hexes on Tag Edit Page (#12770) [deploy]

* Updates default bg_color and text_color hexes on tag edit page

* Removes duplicate placeholder from edit.html.erb
This commit is contained in:
Julianna Tetreault 2021-02-23 14:17:22 -07:00 committed by GitHub
parent 351d4f8da7
commit 3a7e8cb8e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 77 additions and 2 deletions

View file

@ -54,12 +54,12 @@
<div class="tag-form-field">
<%= label_tag :bg_color_hex %>
<br>
<%= color_field_tag "tag[bg_color_hex]", @tag.bg_color_hex, placeholder: "Click for color picker", class: "tag-form-text-field" %>
<%= color_field_tag "tag[bg_color_hex]", @tag.bg_color_hex.presence || "#000000", placeholder: "#000000", class: "tag-form-text-field" %>
</div>
<div class="tag-form-field">
<%= label_tag :text_color_hex %>
<br>
<%= color_field_tag "tag[text_color_hex]", @tag.text_color_hex, placeholder: "Click for color picker", class: "tag-form-text-field" %>
<%= color_field_tag "tag[text_color_hex]", @tag.text_color_hex.presence || "#ffffff", placeholder: "#ffffff", class: "tag-form-text-field" %>
</div>
<div class="tag-form-field">
<%= label_tag :short_summary %>

View file

@ -0,0 +1,75 @@
require "rails_helper"
RSpec.describe "User updates a tag", type: :system do
let(:super_admin) { create(:user, :super_admin) }
let(:tag_moderator) { create(:user) }
let(:tag) { create(:tag) }
describe "UPDATE /t/:tag/edit as a super_admin" do
context "when no colors have been choosen for the tag" do
before do
sign_in super_admin
visit "/t/#{tag}/edit"
end
it "defaults to white text for the color picker" do
expect(page).to have_field("tag_text_color_hex", with: "#ffffff")
end
it "defaults to black and white upon update", :aggregate_failures do
click_button("SAVE CHANGES")
tag.reload
expect(tag.bg_color_hex).to eq("#000000")
expect(tag.text_color_hex).to eq("#ffffff")
end
end
context "when colors have already been choosen for the tag" do
before do
sign_in super_admin
visit "/t/#{tag}/edit"
end
it "remains the same color it was unless otherwise updated via the color picker", :aggregate_failures do
click_button("SAVE CHANGES")
expect(tag.bg_color_hex).to eq(tag.bg_color_hex)
expect(tag.text_color_hex).to eq(tag.text_color_hex)
end
end
end
describe "UPDATE /t/:tag/edit as a tag_moderator" do
context "when no colors have been choosen for the tag" do
before do
tag_moderator.add_role(:tag_moderator, tag)
sign_in tag_moderator
visit "/t/#{tag}/edit"
end
it "defaults to white text for the color picker" do
expect(page).to have_field("tag_text_color_hex", with: "#ffffff")
end
it "defaults to black and white upon update", :aggregate_failures do
click_button("SAVE CHANGES")
tag.reload
expect(tag.bg_color_hex).to eq("#000000")
expect(tag.text_color_hex).to eq("#ffffff")
end
end
context "when colors have already been choosen for the tag" do
before do
tag_moderator.add_role(:tag_moderator, tag)
sign_in tag_moderator
visit "/t/#{tag}/edit"
end
it "remains the same color it was unless otherwise updated via the color picker", :aggregate_failures do
click_button("SAVE CHANGES")
expect(tag.bg_color_hex).to eq(tag.bg_color_hex)
expect(tag.text_color_hex).to eq(tag.text_color_hex)
end
end
end
end