Skip to content

Commit

Permalink
Small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hlcfan committed Feb 15, 2019
1 parent 1246b6e commit 37d41cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/models/room.rb
Expand Up @@ -195,6 +195,10 @@ def async_votes_hash current_user_id
end
end

def closed?
Room::DRAW == status
end

private

def summary_by_condition stories_list
Expand Down
6 changes: 4 additions & 2 deletions app/views/rooms/leaflets/view.html.erb
Expand Up @@ -16,10 +16,12 @@
<div class="clearfix">
<div class="pull-left"><h3 class="leaflet__name"><%= @room.name %></h3></div>
<div class="btn-group pull-right" role="group">
<a href="<%= edit_room_path(@room.slug) %>" class="btn btn-default">✏️ Edit room</a>
<% if !@room.closed? %>
<a href="<%= edit_room_path(@room.slug) %>" class="btn btn-default">✏️ Edit room</a>
<% end %>
<button type="button" onClick="copyToClipboard()" class="btn btn-default" data-toggle="tooltip" data-placement="bottom" data-original-title="" title="">📻 Share link</button>
<a href="<%= summary_room_path(@room.slug)%>" class="btn btn-default ">📊 Summary</a>
<% if "draw" != @room.state %>
<% if !@room.closed? %>
<%= link_to "🏁 Close room", set_room_status_room_path(@room.slug, status: "draw"), remote: true, method: "post", "data-confirm": "Are you sure to close current room?", class: "btn btn-default"%>
<% end %>
</div>
Expand Down
12 changes: 12 additions & 0 deletions spec/models/room_spec.rb
Expand Up @@ -473,4 +473,16 @@
expect(room.async_votes_hash(user.id)).to eq({story.id => { :point => "13", :comment => "My comments" }})
end
end

describe "#closed?" do
it "returns true if room is closed" do
room.status = 2
expect(room.closed?).to be true
end

it "returns false if room is not closed" do
room.status = 1
expect(room.closed?).to be false
end
end
end

0 comments on commit 37d41cb

Please sign in to comment.