Skip to content

Commit

Permalink
[REFACTOR] Prefix project-scoped routes with project
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-contreras committed Jun 16, 2023
1 parent e4142af commit cf9e2ad
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion modules/meeting/app/views/meetings/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ See COPYRIGHT and LICENSE files for more details.
<%= toolbar title: t(:label_meeting_plural) do %>
<% if authorize_for(:meetings, :new) %>
<li class="toolbar-item">
<a href="<%= new_meeting_path %>"
<a href="<%= polymorphic_path([:new , @project, :meeting]) %>"
id="add-meeting-button"
title="<%= I18n.t(:label_meeting_new) %>"
arial-label="<%= I18n.t(:label_meeting_new) %>"
Expand Down
6 changes: 3 additions & 3 deletions modules/meeting/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#++

OpenProject::Application.routes.draw do
scope 'projects/:project_id' do
resources :meetings, only: %i[new create index]
resources :projects, only: %i[] do
resources :meetings, only: %i[index new create]
end

resources :meetings, except: %i[new create] do
resources :meetings do
resource :agenda, controller: 'meeting_agendas', only: [:update] do
member do
get :history
Expand Down
2 changes: 1 addition & 1 deletion modules/meeting/spec/features/meetings_copy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
end

it 'copying a meeting' do
visit meetings_path(project)
visit project_meetings_path(project)

click_link meeting.title

Expand Down
18 changes: 10 additions & 8 deletions modules/meeting/spec/features/meetings_delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,17 @@
let!(:meeting) { create(:meeting, project:, title: 'Own awesome meeting!', author: user) }
let!(:other_meeting) { create(:meeting, project:, title: 'Other awesome meeting!', author: other_user) }

let(:index_path) { project_meetings_path(project) }

before do
login_as(user)
end

context 'with permission to delete meetings', js: true do
let(:permissions) { %i[view_meetings delete_meetings] }

it 'can delete own and other`s meetings' do
visit meetings_path(project)
it "can delete own and other's meetings" do
visit index_path

SeleniumHubWaiter.wait
click_link meeting.title
Expand All @@ -62,7 +64,7 @@
page.accept_confirm

expect(page)
.to have_current_path meetings_path(project)
.to have_current_path index_path

SeleniumHubWaiter.wait
click_link other_meeting.title
Expand All @@ -74,22 +76,22 @@
expect(page)
.to have_content(I18n.t('.no_results_title_text', cascade: true))

expect(current_path)
.to eql meetings_path(project)
expect(page)
.to have_current_path index_path
end
end

context 'without permission to delete meetings' do
let(:permissions) { %i[view_meetings] }

it 'cannot delete own and other`s meetings' do
visit meetings_path(project)
it "cannot delete own and other's meetings" do
visit index_path

click_link meeting.title
expect(page)
.not_to have_link 'Delete'

visit meetings_path(project)
visit index_path

click_link other_meeting.title
expect(page)
Expand Down
2 changes: 1 addition & 1 deletion modules/meeting/spec/support/pages/meetings/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def navigate_by_modules_menu
end

def path
meetings_path(project)
polymorphic_path([project, :meetings])
end
end
end
2 changes: 1 addition & 1 deletion modules/meeting/spec/support/pages/meetings/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def invite(user)
end

def path
new_meeting_path(project)
polymorphic_path([:new, project, :meeting])
end
end
end

0 comments on commit cf9e2ad

Please sign in to comment.