Browse Source

Initial controllers

Dmitry Yu Okunev 5 years ago
parent
commit
41ae920edb

+ 3 - 0
app/assets/javascripts/help.coffee

@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/

+ 3 - 0
app/assets/javascripts/units.coffee

@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/

+ 3 - 0
app/assets/stylesheets/help.scss

@@ -0,0 +1,3 @@
+// Place all the styles related to the Help controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/

+ 3 - 0
app/assets/stylesheets/units.scss

@@ -0,0 +1,3 @@
+// Place all the styles related to the Units controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/

+ 2 - 2
app/controllers/application_controller.rb

@@ -1,3 +1,3 @@
-class ApplicationController < ActionController::Base
-  protect_from_forgery with: :exception
+class ApplicationController < ActionController::API
+	#protect_from_forgery with: :exception
 end

+ 5 - 0
app/controllers/appointments_controller.rb

@@ -0,0 +1,5 @@
+class AppointmentsController < ApplicationController
+	def index
+		render json: Appointment.all
+	end
+end

+ 8 - 0
app/controllers/help_controller.rb

@@ -0,0 +1,8 @@
+class HelpController < ApplicationController
+
+	def index
+		@routes = Rails.application.routes.routes
+		@paths  = @routes.collect{ |r| r.path.spec.to_s }
+		render json: @paths
+	end
+end

+ 5 - 0
app/controllers/people_controller.rb

@@ -0,0 +1,5 @@
+class PeopleController < ApplicationController
+	def index
+		render json: Person.all
+	end
+end

+ 5 - 0
app/controllers/units_controller.rb

@@ -0,0 +1,5 @@
+class UnitsController < ApplicationController
+	def index
+		render json: Unit.all
+	end
+end

+ 2 - 0
app/helpers/help_helper.rb

@@ -0,0 +1,2 @@
+module HelpHelper
+end

+ 2 - 0
app/helpers/units_helper.rb

@@ -0,0 +1,2 @@
+module UnitsHelper
+end

+ 2 - 0
app/views/units/show.html.erb

@@ -0,0 +1,2 @@
+<h1>Units#show</h1>
+<p>Find me in app/views/units/show.html.erb</p>

+ 6 - 5
config/application.rb

@@ -7,9 +7,10 @@ require 'rails/all'
 Bundler.require(*Rails.groups)
 
 module Site
-  class Application < Rails::Application
-    # Settings in config/environments/* take precedence over those specified here.
-    # Application configuration should go into files in config/initializers
-    # -- all .rb files in that directory are automatically loaded.
-  end
+	class Application < Rails::Application
+		config.api_only = true
+		# Settings in config/environments/* take precedence over those specified here.
+		# Application configuration should go into files in config/initializers
+		# -- all .rb files in that directory are automatically loaded.
+	end
 end

+ 6 - 1
config/routes.rb

@@ -1,3 +1,8 @@
 Rails.application.routes.draw do
-  # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+	resources :people
+	resources :units
+	resources :appointments
+
+	# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
+	root to: "help#index"
 end

+ 7 - 0
test/controllers/appointments_controller_test.rb

@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class AppointmentsControllerTest < ActionDispatch::IntegrationTest
+  # test "the truth" do
+  #   assert true
+  # end
+end

+ 7 - 0
test/controllers/help_controller_test.rb

@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class HelpControllerTest < ActionDispatch::IntegrationTest
+  # test "the truth" do
+  #   assert true
+  # end
+end

+ 7 - 0
test/controllers/people_controller_test.rb

@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class PeopleControllerTest < ActionDispatch::IntegrationTest
+  # test "the truth" do
+  #   assert true
+  # end
+end

+ 9 - 0
test/controllers/units_controller_test.rb

@@ -0,0 +1,9 @@
+require 'test_helper'
+
+class UnitsControllerTest < ActionDispatch::IntegrationTest
+  test "should get show" do
+    get units_show_url
+    assert_response :success
+  end
+
+end