* Remove extraneous comment (see 9361d2 and 5c18f8) * Flexible, multiple reaction types * Fix reaction counts * Re-use svg for active state for now * Update yml, update spec * Possible temp fix for failing tests * Colorize reaction icon svgs * Reaction engagement above post title * Index reactions engagements (for logged-out) * Maybe readinglist is special * Try using crayons' dropdown as a drawer? * readinglist isn't really public now * feat: update the styles for the reaction drawer * Grey background highlight, turn off border/shadow * Read our feature flag docs, saw this was recommended * Missed fifth emoji: party/tada * Fix JS test errors * Update test with tada * Suppress flashing engagements when no public reactions * Liberate jump-to-comments from unicorn replacement * 'Add reaction' on tooltip * Don't show reaction emoji on index unless it's been used * rubocop * Update heart+ total count when toggling * Do not include 'readinglist' in drawer/public counts * Fix semi-public readinglist so that icon is badged for current user * Tweak heart-plus svg * Style tweak: border on active reaction * Show reacted icon on drawer trigger for 1.5 sec * Tweak styles for engagements bar * Style tweaks for multiple engagements (#index) * Trying to get size working through crayons/inline_svg * Sparkle hearts * Restore unicorn * Make heart-plus-active work when user has an active reaction * Try 'hoverdown' a dropdown that activates with hover * Long touch? * Tap *outside* the drawer to close * Mobile reaction drawer is also supposed to be columns * More reaction count cleanup * Final emoticons maybe? * Fix reaction bug when feature disabled * Remove readinglist from public reaction counts * Update specs for new reaction categories * Shuffle makes specs flaky * Order does not matter * rubocop * Update to preserve readinglist analytics * Shuffle makes specs flaky * Fix flickering images, remove icon highlight for now * Don't update total for readinglist * reactions_by_user_id * Try renaming this observer function * Try unid ids for SVGs * Remove local test file * Simplistic test for the unique svg transform * Fix javascript for current SVG * Signifcant string literals in this case, rubocop * Use the right expected output Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
111 lines
3.3 KiB
Ruby
111 lines
3.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe ReactionCategory do
|
|
let(:attributes_hash) do
|
|
{
|
|
"slug" => "lol",
|
|
"name" => "Laughing",
|
|
"position" => 2,
|
|
:published => true
|
|
}
|
|
end
|
|
|
|
it "returns category object via [:slug]" do
|
|
expect(described_class[:like]).to be_a(described_class)
|
|
expect(described_class[:vomit].slug).to eq(:vomit)
|
|
expect(described_class[:thumbsdown].name).to eq("Thumbsdown")
|
|
end
|
|
|
|
it "lists all category slugs" do
|
|
expect(described_class.all_slugs).to contain_exactly(*%i[exploding-head fire hands like
|
|
raised_hands readinglist thinking
|
|
thumbsdown thumbsup unicorn vomit])
|
|
end
|
|
|
|
it "lists public categories" do
|
|
expect(described_class.public).to contain_exactly(*%i[like unicorn raised_hands fire exploding-head])
|
|
end
|
|
|
|
it "lists privileged categories" do
|
|
expect(described_class.privileged).to contain_exactly(*%i[thumbsup thumbsdown vomit])
|
|
end
|
|
|
|
it "lists negative_privileged categories" do
|
|
expect(described_class.negative_privileged).to contain_exactly(*%i[thumbsdown vomit])
|
|
end
|
|
|
|
it "initializes via an attributes hash" do
|
|
attributes = attributes_hash
|
|
|
|
initialized = described_class.new attributes
|
|
expect(initialized.slug).to eq(:lol)
|
|
expect(initialized.name).to eq("Laughing")
|
|
expect(initialized.position).to eq(2)
|
|
expect(initialized).to be_published
|
|
expect(initialized).not_to be_privileged
|
|
end
|
|
|
|
it "name defaults to Slug" do
|
|
slugged = described_class.new(slug: "my_name_is")
|
|
expect(slugged.name).to eq("My Name Is")
|
|
end
|
|
|
|
it "score defaults to 1.0" do
|
|
default = described_class.new
|
|
expect(default.score.to_s).to eq("1.0")
|
|
|
|
scored = described_class.new(score: 20.0)
|
|
expect(scored.score.to_s).to eq("20.0")
|
|
end
|
|
|
|
it "privileged defaults to false" do
|
|
default = described_class.new
|
|
expect(default).not_to be_privileged
|
|
|
|
privileged = described_class.new(privileged: true)
|
|
expect(privileged).to be_privileged
|
|
end
|
|
|
|
it "published defaults to true" do
|
|
default = described_class.new
|
|
expect(default).to be_published
|
|
|
|
unpublished = described_class.new(published: false)
|
|
expect(unpublished).not_to be_published
|
|
end
|
|
|
|
it "position defaults to 99" do
|
|
default = described_class.new
|
|
expect(default.position).to eq(99)
|
|
|
|
positioned = described_class.new(position: 4)
|
|
expect(positioned.position).to eq(4)
|
|
end
|
|
|
|
it "is positive when score is above zero" do
|
|
positive = described_class.new(score: 15.0)
|
|
expect(positive).to be_positive
|
|
|
|
negative = described_class.new(score: -1.0)
|
|
expect(negative).not_to be_positive
|
|
end
|
|
|
|
it "is negative when score is below zero" do
|
|
positive = described_class.new(score: 15.0)
|
|
expect(positive).not_to be_negative
|
|
|
|
negative = described_class.new(score: -1.0)
|
|
expect(negative).to be_negative
|
|
end
|
|
|
|
it "is visible_to_public when non-privileged and public" do
|
|
privileged = described_class.new(privileged: true)
|
|
expect(privileged).not_to be_visible_to_public
|
|
|
|
unpublished = described_class.new(published: false)
|
|
expect(unpublished).not_to be_visible_to_public
|
|
|
|
visible = described_class.new(privileged: false, published: true)
|
|
expect(visible).to be_visible_to_public
|
|
end
|
|
end
|