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
This commit is contained in:
parent
6a79c85e6b
commit
aa7ef577cb
3 changed files with 39 additions and 1 deletions
|
|
@ -86,7 +86,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.label :text_color_hex %>
|
||||
<%= f.color_field :text_color_hex, class: "form-control", required: true %>
|
||||
<%= f.color_field :text_color_hex, class: "form-control", required: true, value: @tag.text_color_hex.presence || "#ffffff" %>
|
||||
</div>
|
||||
<%= f.submit class: "btn btn-primary float-right" %>
|
||||
<% end %>
|
||||
|
|
|
|||
38
spec/system/admin/admin_updates_tag_spec.rb
Normal file
38
spec/system/admin/admin_updates_tag_spec.rb
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "Admin updates a tag", type: :system do
|
||||
let(:super_admin) { create(:user, :super_admin) }
|
||||
let(:tag) { create(:tag) }
|
||||
|
||||
context "when no colors have been choosen for the tag" do
|
||||
before do
|
||||
sign_in super_admin
|
||||
visit "/admin/tags/#{tag.id}"
|
||||
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" do
|
||||
check "Supported"
|
||||
click_button("Update Tag")
|
||||
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 "/admin/tags/#{tag.id}"
|
||||
end
|
||||
|
||||
it "remains the same color it was unless otherwise updated via the color picker" do
|
||||
click_button("Update Tag")
|
||||
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
|
||||
Loading…
Add table
Reference in a new issue