moves the admin api inside of the /admin namespace
This commit is contained in:
3
app/controllers/admin/api/base_controller.rb
Normal file
3
app/controllers/admin/api/base_controller.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Admin::Api::BaseController < Admin::BaseController
|
||||
protect_from_forgery with: :null_session
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
class Api::StatsController < Api::ApiController
|
||||
class Admin::Api::StatsController < Admin::Api::BaseController
|
||||
|
||||
def show
|
||||
unless params[:events].present? || params[:visits].present?
|
||||
@@ -1,13 +0,0 @@
|
||||
class Api::ApiController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
protect_from_forgery with: :null_session
|
||||
|
||||
skip_authorization_check
|
||||
before_action :verify_administrator
|
||||
|
||||
private
|
||||
|
||||
def verify_administrator
|
||||
raise CanCan::AccessDenied unless current_user.try(:administrator?)
|
||||
end
|
||||
end
|
||||
@@ -3,14 +3,14 @@ module StatsHelper
|
||||
def events_chart_tag(events, opt={})
|
||||
events = events.join(',') if events.is_a? Array
|
||||
opt[:data] ||= {}
|
||||
opt[:data][:graph] = api_stats_path(events: events)
|
||||
opt[:data][:graph] = admin_api_stats_path(events: events)
|
||||
content_tag :div, "", opt
|
||||
end
|
||||
|
||||
def visits_chart_tag(opt={})
|
||||
events = events.join(',') if events.is_a? Array
|
||||
opt[:data] ||= {}
|
||||
opt[:data][:graph] = api_stats_path(visits: true)
|
||||
opt[:data][:graph] = admin_api_stats_path(visits: true)
|
||||
content_tag :div, "", opt
|
||||
end
|
||||
|
||||
|
||||
@@ -115,6 +115,10 @@ Rails.application.routes.draw do
|
||||
|
||||
resource :activity, controller: :activity, only: :show
|
||||
resource :stats, only: :show
|
||||
|
||||
namespace :api do
|
||||
resource :stats, only: :show
|
||||
end
|
||||
end
|
||||
|
||||
namespace :moderation do
|
||||
@@ -155,9 +159,7 @@ Rails.application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
namespace :api do
|
||||
resource :stats, only: [:show]
|
||||
end
|
||||
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Api::StatsController do
|
||||
describe Admin::Api::StatsController do
|
||||
|
||||
describe 'GET index' do
|
||||
let(:user) { create(:administrator).user }
|
||||
Reference in New Issue
Block a user