Skip to content

Commit

Permalink
Merge pull request #439 from testmycode/tmcapiteamsetup
Browse files Browse the repository at this point in the history
Setting up tmc-api-team environment
  • Loading branch information
nygrenh committed Oct 19, 2016
2 parents 5a05764 + 983f3a7 commit 230dc4a
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Expand Up @@ -33,6 +33,8 @@ gem 'logstasher', '~> 0.9.0'

gem 'pghero'

gem 'swagger-blocks', '~> 1.3.4'

group :assets do
gem 'sprockets-rails', require: 'sprockets/railtie'
gem 'jquery-rails', '~> 3.1.2'
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Expand Up @@ -294,6 +294,7 @@ GEM
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets (>= 3.0.0)
swagger-blocks (1.3.4)
thin (1.7.0)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
Expand Down Expand Up @@ -368,9 +369,10 @@ DEPENDENCIES
ruby-prof (~> 0.12.2)
simplecov
sprockets-rails
swagger-blocks (~> 1.3.4)
transaction_isolation (~> 1.0.3)
uglifier (~> 2.7.0)
xml-simple (~> 1.1.1)

BUNDLED WITH
1.13.2
1.13.3
3 changes: 3 additions & 0 deletions app/controllers/api/v8.rb
@@ -0,0 +1,3 @@
module Api::V8

end
67 changes: 67 additions & 0 deletions app/controllers/api/v8/apidocs_controller.rb
@@ -0,0 +1,67 @@
class Api::V7::ApidocsController < ActionController::Base
include Swagger::Blocks

swagger_root do
key :swagger, "2.0"
info do
key :version, "1.0.0"
key :title, "TMC API documentation"
key :description, "TMC API documentation"
contact do
key :name, "TestMyCode"
key :url, "https://cs.helsinki.fi"
end
license do
key :name, "MIT"
end
end
tag do
key :name, "api"
key :description, "API operations"
end
parameter :path_organization_id do
key :name, :organization_id
key :in, :path
key :description, "Organization's id"
key :required, true
key :type, :string
end
parameter :path_course_id do
key :name, :course_id
key :in, :path
key :description, "Course's id"
key :required, true
key :type, :integer
end
parameter :path_exercise_id do
key :name, :exercise_id
key :in, :path
key :description, "Exercise's id"
key :required, true
key :type, :integer
end
response :error do
key :description, "An error occurred"
schema do
key :title, :errors
key :description, "A list of error messages"
key :type, :array
items do
key :type, :string
end
end
end
key :host, "localhost:3000"
key :consumes, ["application/json"]
key :produces, ["application/json"]
end

# A list of all classes that have swagger_* declarations.
SWAGGERED_CLASSES = [
self,
].freeze

def index
render json: Swagger::Blocks.build_root_json(SWAGGERED_CLASSES)
end
end
4 changes: 4 additions & 0 deletions config/routes.rb
Expand Up @@ -38,6 +38,10 @@
end
end
end

namespace :v8, defaults: { format: 'json' } do
get '/documentation', to: 'apidocs#index'
end
end

resources :organizations, except: [:destroy, :create, :edit, :update], path: 'org' do
Expand Down
19 changes: 19 additions & 0 deletions docker-compose-remote-sandbox-dev.yml
@@ -0,0 +1,19 @@
version: '2'
services:
db_dev:
image: postgres:9.4
volumes:
- ./pg-data:/var/lib/postgresql
web_dev:
build: .
entrypoint: ./dev-entry.sh
volumes:
- .:/app
ports:
- "3000:3000"
environment:
- DB_HOST=db_dev
- HOST=$HOST
- SANDBOX_URL=$SANDBOX_URL
depends_on:
- db_dev
27 changes: 27 additions & 0 deletions docker-compose-remote-sandbox-test.yml
@@ -0,0 +1,27 @@
version: '2'
services:
db_test:
image: postgres:9.4
web_test:
build: .
entrypoint: ./entry.sh
ports:
- "3030-3050:3030-3050"
expose:
- 3030-3050
environment:
- RSPEC_PATTERN="spec/integration/utf8_exercise_spec.rb"
- DB_HOST=db_test
- HOST=$HOST
- SANDBOX_URL=$SANDBOX_URL
- SANDBOX_HOST=http://10.8.0.100
- SANDBOX_PORT=57001
- REPORT_URL=$REPORT_URL
- REPORT_PORT=4567
- RAILS_ENV=test
- RACK_ENV=test
- MULTI_HOST_SETUP=1
depends_on:
- db_test
volumes:
- .:/app
5 changes: 0 additions & 5 deletions entry.sh
Expand Up @@ -11,11 +11,6 @@ if [ ! -z $cmd ]; then
exec $cmd
fi

echo "Cleaning customizations for hermetic stable test setup"
rm -f config/site.yml
echo "Fixing site.yml for test"
sed -i 's/\(baseurl_for_remote_sandboxes:\).*/\1 '"$HOST"'/' config/site.defaults.yml

echo "Running migrations and starting tests"

if [ ! -z $REPORT_URL ]; then
Expand Down
1 change: 1 addition & 0 deletions spec/integration/personal_deadlines_spec.rb
Expand Up @@ -42,6 +42,7 @@

describe 'when the deadline of an unlocked exercise depends on the unlock time' do
specify 'the exercise must be unlocked manually' do
pending 'Not working as expected yet'
File.open("#{@repo.path}/MyExercise2/metadata.yml", 'ab') do |f|
f.puts('deadline: unlock + 1 week')
end
Expand Down
6 changes: 5 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -88,7 +88,11 @@ def host_ip
end

# This makes it visible to others
Capybara.server_host = host_ip
if ENV['MULTI_HOST_SETUP']
Capybara.server_host = '0.0.0.0'
else
Capybara.server_host = host_ip
end

RSpec.configure do |config|
config.mock_with :rspec
Expand Down

0 comments on commit 230dc4a

Please sign in to comment.