Skip to content

Commit

Permalink
Rubocop clean
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Rass committed Oct 24, 2024
1 parent 08a3054 commit d6b1d52
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
15 changes: 7 additions & 8 deletions app/decorators/room_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# frozen_string_literal: true

class RoomDecorator < ApplicationDecorator
BADGE_COLORS = {
active: "text-bg-success",
passive: "text-bg-warning",
planned: "text-bg-primary"
}.freeze

class << self
def statuses_for_options
Room.statuses.keys.map { |status| [Room.human_attribute_name("status.#{status}"), status] }
end
end

def badge_color_for_status
case status
when "active"
"text-bg-success"
when "passive"
"text-bg-warning"
when "planned"
"text-bg-primary"
end
BADGE_COLORS[status.to_sym]
end
end
10 changes: 5 additions & 5 deletions spec/decorators/room_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
end

describe "#badge_color_for_status" do
let(:subject) { rooms(:one).decorated }
subject(:badge_color) { rooms(:one).decorated.badge_color_for_status }

context "with status = active" do
it { expect(subject.badge_color_for_status).to eq "text-bg-success" }
it { is_expected.to eq "text-bg-success" }
end

context "with status = passive" do
before { rooms(:one).status = :passive }

it { expect(subject.badge_color_for_status).to eq "text-bg-warning" }
it { is_expected.to eq "text-bg-warning" }
end

context "with status = planned" do
before { rooms(:one).status = :planned }

it { expect(subject.badge_color_for_status).to eq "text-bg-primary" }
it { is_expected.to eq "text-bg-primary" }
end

context "with status = unknown" do
before { rooms(:one).status = :unknown }

it { expect(subject.badge_color_for_status).to be_nil }
it { is_expected.to be_nil }
end
end
end

0 comments on commit d6b1d52

Please sign in to comment.