Skip to content

Commit

Permalink
/api -> /legacy_api
Browse files Browse the repository at this point in the history
  • Loading branch information
timhabermaas committed Sep 5, 2022
1 parent d73d0cb commit 381a72b
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/collections/records.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Cubemania.Collections.Records extends Backbone.Collection
record.get("amount")

url: ->
"/api/puzzles/" + @puzzleId + "/records?page=#{@currentPage()}&type=#{@getType()}"
"/legacy_api/puzzles/" + @puzzleId + "/records?page=#{@currentPage()}&type=#{@getType()}"

initialize: (models, options) ->
if options?
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/collections/singles.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Cubemania.Collections.Singles extends Backbone.Collection
model: Cubemania.Models.Single

url: ->
"/api/puzzles/" + @puzzleId + "/singles"
"/legacy_api/puzzles/" + @puzzleId + "/singles"

comparator: (single) ->
single.get("created_at")
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/views/timer/chart.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Cubemania.Views.Chart extends Backbone.View
$(@el).html(@template())
@$("p.help").hide()

@$("#user-tokens").tokenInput "/api/users.json",
@$("#user-tokens").tokenInput "/legacy_api/users.json",
crossDomain: false
theme: "facebook"
preventDuplicates: true
Expand Down Expand Up @@ -189,7 +189,7 @@ class Cubemania.Views.Chart extends Backbone.View
# TODO add convenient function for zooming on current day
fetchDataForChart: (userId, from, to, callback) ->
puzzleId = Cubemania.currentPuzzle.getId()
$.getJSON "/api/puzzles/#{puzzleId}/singles/chart.json?from=#{from}&to=#{to}&user_id=#{userId}", (data) =>
$.getJSON "/legacy_api/puzzles/#{puzzleId}/singles/chart.json?from=#{from}&to=#{to}&user_id=#{userId}", (data) =>
callback(@generateChartDataFromApiData data)

addUserToChart: (id, name) ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Api::ApiController < ActionController::Base
class LegacyApi::ApiController < ActionController::Base
include Authentication

load_and_authorize_resource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Api
module LegacyApi
class RecordsController < ApiController
def index
puzzle = Puzzle.find params[:puzzle_id]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Api
module LegacyApi
# TODO get rid of instance variables by using cached instance methods
class SinglesController < ApiController
respond_to :json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Api
module LegacyApi
class UsersController < ApiController
def index
@users = User.order('singles_count desc').paginate(:page => params[:page], :per_page => 200)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Cubemania::Application.routes.draw do
root :to => 'homes#show'

namespace :api do
namespace :legacy_api do
resources :users
resources :puzzles do
resources :singles do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/api/access_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe "Access", :type => :api do
it "renders a 401 response when user's not logged in" do
post "/api/puzzles/3x3x3/singles.json"
post "/legacy_api/puzzles/3x3x3/singles.json"
expect(last_response.status).to eq(401)
end
end
6 changes: 3 additions & 3 deletions spec/features/api/singles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

describe "no date range given" do
it "returns singles grouped by month" do
get "/api/puzzles/#{puzzle.id}/singles/chart.json", :user_id => @user.id
get "/legacy_api/puzzles/#{puzzle.id}/singles/chart.json", :user_id => @user.id
result = JSON.parse(last_response.body)
expect(result).to have(2).items
expect(result[0]["time"]).to eq(15000)
Expand All @@ -31,7 +31,7 @@

describe "date range of one month" do
it "returns singles grouped by day" do
get "/api/puzzles/#{puzzle.id}/singles/chart.json", :user_id => @user.id,
get "/legacy_api/puzzles/#{puzzle.id}/singles/chart.json", :user_id => @user.id,
:from => Time.new(2012, 4, 1).to_i,
:to => Time.new(2012, 5, 1).to_i
result = JSON.parse(last_response.body)
Expand All @@ -49,7 +49,7 @@
create :single, :user => user, :puzzle => puzzle, :time => 13, :created_at => time_zone.local(2012, 10, 4, 23, 30)
create :single, :user => user, :puzzle => puzzle, :time => 15, :created_at => time_zone.local(2012, 10, 5, 0, 30)

get "/api/puzzles/#{puzzle.id}/singles/chart.json", :user_id => user.id,
get "/legacy_api/puzzles/#{puzzle.id}/singles/chart.json", :user_id => user.id,
:from => Time.new(2012, 10, 1).to_i,
:to => Time.new(2012, 10, 30).to_i
result = JSON.parse(last_response.body)
Expand Down

0 comments on commit 381a72b

Please sign in to comment.