Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issuenumber5/#319/results only addable after start date #549

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def leave

# GET /events/1/schedule
def schedule
authorize! :play_matches, @event
if @event.matches.empty?
@event.generate_schedule
@event.save
Expand Down
1 change: 1 addition & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def initialize_with_user(user)
can [:create, :read, :update, :destroy], Event, owner_id: user_id
can_join_event(user)
can_leave_event(user)
can :play_matches, Event do |event| event.startdate <= Date.current end
can :ranking, Event
can [:schedule, :team_join], Event
can_update_gameday(user)
Expand Down
2 changes: 0 additions & 2 deletions app/views/application/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<% end %>
<%= menu_item Team.model_name.human(:count => :many).titleize, teams_path, class: 'text-center' %>
<%= menu_item Event.model_name.human(:count => :many).titleize, events_path, class: 'text-center' %>
<%= menu_item t('events.create_event'), new_event_path, class: 'text-center' %>
</div>
<% end %>
<% else %>
Expand All @@ -48,7 +47,6 @@
<% end %>
<%= menu_item Team.model_name.human(:count => :many).titleize, teams_path %>
<%= menu_item Event.model_name.human(:count => :many).titleize, events_path %>
<%= menu_item t('events.create_event'), new_event_path %>
<% if user_signed_in? %>
<%= drop_down (image_tag current_user.avatar_url || 'https://owncloud.hpi.de/index.php/s/57REqYtqsah3A7o/download', class: 'avatar') + " #{current_user.first_name}" do %>
<!--Fill in more drop down menu items-->
Expand Down
8 changes: 5 additions & 3 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@
</table>
</div>
<% if @event.type != 'Rankinglist' %>
<%= link_to t('.to_schedule'),
event_schedule_path(@event),
class: 'btn btn-default'%>
<% if can? :play_matches, @event %>
<%= link_to t('.to_schedule'),
event_schedule_path(@event),
class: 'btn btn-default'%>
<% end %>

<%= link_to t('.to_overview'),
event_overview_path(@event),
Expand Down
1 change: 1 addition & 0 deletions spec/controllers/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
describe "GET #show" do
it "returns a success response" do
event = Event.create! valid_event_attributes
event.startdate = Date.yesterday
get :show, params: { id: event.to_param }, session: valid_session
expect(response).to be_success
end
Expand Down
2 changes: 1 addition & 1 deletion spec/features/event/schedule_league_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@league = FactoryBot.create :league, :single_player
@user = FactoryBot.create :user
@another_user = FactoryBot.create :user

@league.startdate = Date.yesterday
@league.add_participant(@user)
@league.add_participant(@another_user)
end
Expand Down