Add empty issue reporters page
This commit is contained in:
parent
34970acc5e
commit
a440afc604
4 changed files with 116 additions and 0 deletions
17
app/controllers/issues/reporters_controller.rb
Normal file
17
app/controllers/issues/reporters_controller.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
module Issues
|
||||
class ReportersController < ApplicationController
|
||||
layout "site"
|
||||
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
before_action :check_database_readable
|
||||
|
||||
authorize_resource :issue
|
||||
|
||||
def index
|
||||
@issue = Issue.visible_to(current_user).find(params[:issue_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to :controller => "/errors", :action => "not_found"
|
||||
end
|
||||
end
|
||||
end
|
0
app/views/issues/reporters/index.html.erb
Normal file
0
app/views/issues/reporters/index.html.erb
Normal file
|
@ -375,6 +375,7 @@ OpenStreetMap::Application.routes.draw do
|
|||
# issues and reports
|
||||
resources :issues do
|
||||
resources :comments, :controller => :issue_comments
|
||||
resources :reporters, :module => :issues, :only => :index
|
||||
member do
|
||||
post "resolve"
|
||||
post "assign"
|
||||
|
|
98
test/controllers/issues/reporters_controller_test.rb
Normal file
98
test/controllers/issues/reporters_controller_test.rb
Normal file
|
@ -0,0 +1,98 @@
|
|||
require "test_helper"
|
||||
|
||||
module Issues
|
||||
class DataControllerTest < ActionDispatch::IntegrationTest
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
assert_routing(
|
||||
{ :path => "/issues/1/reporters", :method => :get },
|
||||
{ :controller => "issues/reporters", :action => "index", :issue_id => "1" }
|
||||
)
|
||||
end
|
||||
|
||||
def test_index_missing_issue_as_moderator
|
||||
session_for(create(:moderator_user))
|
||||
get issue_reporters_path(999111)
|
||||
|
||||
assert_redirected_to :controller => "/errors", :action => :not_found
|
||||
end
|
||||
|
||||
def test_index_missing_issue_as_administrator
|
||||
session_for(create(:administrator_user))
|
||||
get issue_reporters_path(999111)
|
||||
|
||||
assert_redirected_to :controller => "/errors", :action => :not_found
|
||||
end
|
||||
|
||||
def test_index_assigned_to_moderator_as_unauthorized
|
||||
issue = create(:issue, :assigned_role => "moderator")
|
||||
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_redirected_to login_path(:referer => issue_reporters_path(issue))
|
||||
end
|
||||
|
||||
def test_index_assigned_to_moderator_as_regular_user
|
||||
issue = create(:issue, :assigned_role => "moderator")
|
||||
|
||||
session_for(create(:user))
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_redirected_to :controller => "/errors", :action => :forbidden
|
||||
end
|
||||
|
||||
def test_index_assigned_to_moderator_as_administrator
|
||||
issue = create(:issue, :assigned_role => "moderator")
|
||||
|
||||
session_for(create(:administrator_user))
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_redirected_to :controller => "/errors", :action => :not_found
|
||||
end
|
||||
|
||||
def test_index_assigned_to_moderator_as_moderator
|
||||
issue = create(:issue, :assigned_role => "moderator")
|
||||
|
||||
session_for(create(:moderator_user))
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
def test_index_assigned_to_administrator_as_unauthorized
|
||||
issue = create(:issue, :assigned_role => "administrator")
|
||||
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_redirected_to login_path(:referer => issue_reporters_path(issue))
|
||||
end
|
||||
|
||||
def test_index_assigned_to_administrator_as_regular_user
|
||||
issue = create(:issue, :assigned_role => "administrator")
|
||||
|
||||
session_for(create(:user))
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_redirected_to :controller => "/errors", :action => :forbidden
|
||||
end
|
||||
|
||||
def test_index_assigned_to_administrator_as_moderator
|
||||
issue = create(:issue, :assigned_role => "administrator")
|
||||
|
||||
session_for(create(:moderator_user))
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_redirected_to :controller => "/errors", :action => :not_found
|
||||
end
|
||||
|
||||
def test_index_assigned_to_administrator_as_administrator
|
||||
issue = create(:issue, :assigned_role => "administrator")
|
||||
|
||||
session_for(create(:administrator_user))
|
||||
get issue_reporters_path(issue)
|
||||
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue