Skip to content

Commit

Permalink
Initial test controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
richhollis committed Nov 4, 2013
1 parent 0a0493a commit a37d8f2
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
Expand All @@ -32,6 +32,8 @@ group :doc do
gem 'sdoc', require: false
end

gem 'swagger-docs', path: "~/swagger-docs"

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

Expand Down
12 changes: 12 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
PATH
remote: ~/swagger-docs
specs:
swagger-docs (0.0.2)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -46,6 +51,7 @@ GEM
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
libv8 (3.16.14.3)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
Expand All @@ -72,6 +78,7 @@ GEM
rake (10.1.0)
rdoc (3.12.2)
json (~> 1.4)
ref (1.0.5)
sass (3.2.12)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
Expand All @@ -90,6 +97,9 @@ GEM
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
therubyracer (0.12.0)
libv8 (~> 3.16.14.0)
ref
thor (0.18.1)
thread_safe (0.1.3)
atomic
Expand All @@ -115,5 +125,7 @@ DEPENDENCIES
sass-rails (~> 4.0.0)
sdoc
sqlite3
swagger-docs!
therubyracer
turbolinks
uglifier (>= 1.3.0)
16 changes: 16 additions & 0 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class GroupsController < ApplicationController

swagger_controller :groups, "Groups"

swagger_api :index do
summary "Fetches all group memberships"
param :path, :id, :integer, :required, "Group ID"
response :unauthorized
response :not_acceptable
end

def index
render :json => {result:"Success"}, :status => 200
end

end
16 changes: 16 additions & 0 deletions app/controllers/properties_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class PropertiesController < ApplicationController

swagger_controller :properties, "Properties"

swagger_api :show do
summary "Fetches all properties"
param :path, :id, :integer, :required, "Property ID"
response :unauthorized
response :not_acceptable
end

def show
render :json => {result:"Success"}, :status => 200
end

end
15 changes: 15 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class UsersController < ApplicationController

swagger_controller :users, "Users"

swagger_api :index do
summary "Fetches all users"
response :unauthorized
response :not_acceptable
end

def index
render :json => {result:"Success"}, :status => 200
end

end
3 changes: 3 additions & 0 deletions config/initializers/swagger_docs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Swagger::Docs::Config.register_apis({
"1.0" => {:controller_base_path => "", :api_file_path => "public"}
})
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
SwaggerDocsSample::Application.routes.draw do

match '/properties/:id', to: 'properties#show', via: 'get'
match '/users', to: 'users#index', via: 'get'
match '/group/:id/members', to: 'groups#index', via: 'get'

# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".

Expand Down

0 comments on commit a37d8f2

Please sign in to comment.