repia 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +71 -0
- data/Rakefile +1 -0
- data/lib/repia/base_controller.rb +33 -0
- data/lib/repia/{core.rb → base_helper.rb} +12 -53
- data/lib/repia/uuid_model.rb +28 -0
- data/lib/repia/version.rb +1 -1
- data/lib/repia.rb +3 -1
- data/test/dummy/app/models/unique_model.rb +1 -0
- data/test/dummy/config/application.rb +1 -1
- data/test/dummy/config/environments/test.rb +2 -2
- data/test/dummy/log/test.log +1464 -2408
- data/test/repia_base_controller_test.rb +97 -0
- data/test/repia_middlewares_test.rb +20 -0
- data/test/repia_test.rb +0 -66
- data/test/repia_unique_model_test.rb +11 -0
- metadata +33 -27
- data/test/dummy/app/controllers/dummies_controller.rb +0 -36
- data/test/dummy/log/development.log +0 -2
| @@ -0,0 +1,97 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class TestsController < ApplicationController
         | 
| 4 | 
            +
            end
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class TestsControllerTest < ActionController::TestCase
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              setup do
         | 
| 9 | 
            +
                Rails.application.routes.draw do
         | 
| 10 | 
            +
                  match "tests" => "tests#index", via: [:get]
         | 
| 11 | 
            +
                  match "tests/:id" => "tests#show", via: [:get]
         | 
| 12 | 
            +
                  match "tests(/:id)" => "tests#options", via: [:options]
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
                @controller = TestsController.new
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              test "Predefined errors should be handled" do
         | 
| 18 | 
            +
                class ::TestsController
         | 
| 19 | 
            +
                  undef :show if method_defined? :show
         | 
| 20 | 
            +
                  def show
         | 
| 21 | 
            +
                    raise Repia::Errors::STATUS_CODE_TO_ERROR[params[:id].to_i]
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
                [400, 401, 404, 409, 500].each do |status_code|
         | 
| 25 | 
            +
                  get :show, params: { id: status_code }
         | 
| 26 | 
            +
                  assert_response status_code
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              test "options request is handled" do
         | 
| 31 | 
            +
                get :options
         | 
| 32 | 
            +
                assert_response :success
         | 
| 33 | 
            +
                @request.headers["Access-Control-Request-Headers"] = "POST"
         | 
| 34 | 
            +
                get :options
         | 
| 35 | 
            +
                assert_response :success
         | 
| 36 | 
            +
                assert_equal "POST", @response.headers["Access-Control-Allow-Headers"]
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              test "render multiple errors" do
         | 
| 40 | 
            +
                class ::TestsController
         | 
| 41 | 
            +
                  undef :index if method_defined? :index
         | 
| 42 | 
            +
                  def index
         | 
| 43 | 
            +
                    self.render_errors(400, ["foo", "bar"])
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
                get :index
         | 
| 47 | 
            +
                assert_response 400
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              test "handle standard error" do
         | 
| 51 | 
            +
                class ::TestsController
         | 
| 52 | 
            +
                  undef :index if method_defined? :index
         | 
| 53 | 
            +
                  def index
         | 
| 54 | 
            +
                    raise StandardError
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
                get :index
         | 
| 58 | 
            +
                assert_response 500
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              test "find_object will error if object does not exist" do
         | 
| 62 | 
            +
                class ::TestsController
         | 
| 63 | 
            +
                  undef :show if method_defined? :show
         | 
| 64 | 
            +
                  def show
         | 
| 65 | 
            +
                    find_object UniqueModel, params[:id]
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
                get :show, params: { id: "blah" }
         | 
| 69 | 
            +
                assert_response 404
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              test "find_object will find object if exists" do
         | 
| 73 | 
            +
                obj = UniqueModel.new()
         | 
| 74 | 
            +
                obj.save()
         | 
| 75 | 
            +
                class ::TestsController
         | 
| 76 | 
            +
                  undef :show if method_defined? :show
         | 
| 77 | 
            +
                  def show
         | 
| 78 | 
            +
                    find_object UniqueModel, params[:id]
         | 
| 79 | 
            +
                    render json: {}, status: 200
         | 
| 80 | 
            +
                  end
         | 
| 81 | 
            +
                end
         | 
| 82 | 
            +
                get :show, params: { id: obj.uuid }
         | 
| 83 | 
            +
                assert_response 200
         | 
| 84 | 
            +
              end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
              test "exceptions_app" do
         | 
| 87 | 
            +
                class ::TestsController
         | 
| 88 | 
            +
                  undef :show if method_defined? :show
         | 
| 89 | 
            +
                  def show
         | 
| 90 | 
            +
                    @exception = ActionController::RoutingError.new("blah")
         | 
| 91 | 
            +
                    exceptions_app
         | 
| 92 | 
            +
                  end
         | 
| 93 | 
            +
                end
         | 
| 94 | 
            +
                get :show, params: { id: "blah" }
         | 
| 95 | 
            +
                assert_response 404
         | 
| 96 | 
            +
              end
         | 
| 97 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class RepiaTest < ActiveSupport::TestCase
         | 
| 4 | 
            +
              test "HttpMethodNotAllowed middleware throws 405 for invalid HTTP method" do
         | 
| 5 | 
            +
                app = lambda {|env| [200, {}, [""]]}
         | 
| 6 | 
            +
                stack = Repia::HttpMethodNotAllowed.new(app)
         | 
| 7 | 
            +
                request = Rack::MockRequest.new(stack)
         | 
| 8 | 
            +
                response = request.request("DOESNOTEXIST", "/users")
         | 
| 9 | 
            +
                assert response.headers["Content-Type"].include?("application/json")
         | 
| 10 | 
            +
                assert_equal 405, response.status.to_i
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              test "HttpMethodNotAllowed middleware does not throw 405 for valid HTTP method" do
         | 
| 14 | 
            +
                app = lambda {|env| [200, {}, [""]]}
         | 
| 15 | 
            +
                stack = Repia::HttpMethodNotAllowed.new(app)
         | 
| 16 | 
            +
                request = Rack::MockRequest.new(stack)
         | 
| 17 | 
            +
                response = request.request("GET", "/users")
         | 
| 18 | 
            +
                assert_equal 200, response.status.to_i
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
    
        data/test/repia_test.rb
    CHANGED
    
    | @@ -1,71 +1,5 @@ | |
| 1 1 | 
             
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            class RepiaTest < ActiveSupport::TestCase
         | 
| 4 | 
            -
              test "UniqueModel gets assigned a UUID at creation" do
         | 
| 5 | 
            -
                obj = UniqueModel.new()
         | 
| 6 | 
            -
                obj.save()
         | 
| 7 | 
            -
                assert_not_nil obj.uuid
         | 
| 8 | 
            -
              end
         | 
| 9 4 |  | 
| 10 | 
            -
              test "HttpMethodNotAllowed middleware throws 405 for invalid HTTP method" do
         | 
| 11 | 
            -
                app = lambda {|env| [200, {}, [""]]}
         | 
| 12 | 
            -
                stack = Repia::HttpMethodNotAllowed.new(app)
         | 
| 13 | 
            -
                request = Rack::MockRequest.new(stack)
         | 
| 14 | 
            -
                response = request.request("DOESNOTEXIST", "/users")
         | 
| 15 | 
            -
                assert response.headers["Content-Type"].include?("application/json")
         | 
| 16 | 
            -
                assert_equal 405, response.status.to_i
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              test "HttpMethodNotAllowed middleware does not throw 405 for valid HTTP method" do
         | 
| 20 | 
            -
                app = lambda {|env| [200, {}, [""]]}
         | 
| 21 | 
            -
                stack = Repia::HttpMethodNotAllowed.new(app)
         | 
| 22 | 
            -
                request = Rack::MockRequest.new(stack)
         | 
| 23 | 
            -
                response = request.request("GET", "/users")
         | 
| 24 | 
            -
                assert_equal 200, response.status.to_i
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
            end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
            class DummiesControllerTest < ActionController::TestCase
         | 
| 29 | 
            -
              test "Predefined errors should be handled" do
         | 
| 30 | 
            -
                [400, 401, 404, 409, 500].each do |status_code|
         | 
| 31 | 
            -
                  get :show, id: status_code
         | 
| 32 | 
            -
                  assert_response status_code
         | 
| 33 | 
            -
                end
         | 
| 34 | 
            -
              end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
              test "options request is handled" do
         | 
| 37 | 
            -
                get :options
         | 
| 38 | 
            -
                assert_response :success
         | 
| 39 | 
            -
                @request.headers["Access-Control-Request-Headers"] = "POST"
         | 
| 40 | 
            -
                get :options
         | 
| 41 | 
            -
                assert_response :success
         | 
| 42 | 
            -
                assert_equal "POST", @response.headers["Access-Control-Allow-Headers"]
         | 
| 43 | 
            -
              end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
              test "render multiple errors" do
         | 
| 46 | 
            -
                get :index
         | 
| 47 | 
            -
                assert_response 400
         | 
| 48 | 
            -
              end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
              test "handle standard error" do
         | 
| 51 | 
            -
                post :create
         | 
| 52 | 
            -
                assert_response 500
         | 
| 53 | 
            -
              end
         | 
| 54 | 
            -
             | 
| 55 | 
            -
              test "find_object will error if object does not exist" do
         | 
| 56 | 
            -
                patch :update, id: "blah"
         | 
| 57 | 
            -
                assert_response 404
         | 
| 58 | 
            -
              end
         | 
| 59 | 
            -
             | 
| 60 | 
            -
              test "find_object will find object if exists" do
         | 
| 61 | 
            -
                obj = UniqueModel.new()
         | 
| 62 | 
            -
                obj.save()
         | 
| 63 | 
            -
                patch :update, id: obj.uuid
         | 
| 64 | 
            -
                assert_response 200
         | 
| 65 | 
            -
              end
         | 
| 66 | 
            -
             | 
| 67 | 
            -
              test "exceptions_app" do
         | 
| 68 | 
            -
                delete :destroy, id: "blah"
         | 
| 69 | 
            -
                assert_response 404
         | 
| 70 | 
            -
              end
         | 
| 71 5 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,83 +1,83 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: repia
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - David An
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016- | 
| 11 | 
            +
            date: 2016-11-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - ~>
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 19 | 
            +
                    version: 5.0.0
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - - ~>
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version:  | 
| 26 | 
            +
                    version: 5.0.0
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: uuidtools
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 30 | 
             
                requirements:
         | 
| 31 | 
            -
                - - ~>
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 33 | 
             
                    version: 2.1.5
         | 
| 34 34 | 
             
              type: :runtime
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 | 
            -
                - - ~>
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 40 | 
             
                    version: 2.1.5
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 42 | 
             
              name: simplecov
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 | 
            -
                - -  | 
| 45 | 
            +
                - - ">="
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 47 | 
             
                    version: '0'
         | 
| 48 48 | 
             
              type: :runtime
         | 
| 49 49 | 
             
              prerelease: false
         | 
| 50 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 51 | 
             
                requirements:
         | 
| 52 | 
            -
                - -  | 
| 52 | 
            +
                - - ">="
         | 
| 53 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 54 | 
             
                    version: '0'
         | 
| 55 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 56 | 
             
              name: coveralls
         | 
| 57 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 58 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 59 | 
            +
                - - ">="
         | 
| 60 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 61 | 
             
                    version: '0'
         | 
| 62 62 | 
             
              type: :runtime
         | 
| 63 63 | 
             
              prerelease: false
         | 
| 64 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 65 | 
             
                requirements:
         | 
| 66 | 
            -
                - -  | 
| 66 | 
            +
                - - ">="
         | 
| 67 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 68 | 
             
                    version: '0'
         | 
| 69 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 70 | 
             
              name: sqlite3
         | 
| 71 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 72 | 
             
                requirements:
         | 
| 73 | 
            -
                - -  | 
| 73 | 
            +
                - - ">="
         | 
| 74 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 75 | 
             
                    version: '0'
         | 
| 76 76 | 
             
              type: :development
         | 
| 77 77 | 
             
              prerelease: false
         | 
| 78 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 79 | 
             
                requirements:
         | 
| 80 | 
            -
                - -  | 
| 80 | 
            +
                - - ">="
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '0'
         | 
| 83 83 | 
             
            description: It is a collection of basic features required to build RESTful API in
         | 
| @@ -88,19 +88,24 @@ executables: [] | |
| 88 88 | 
             
            extensions: []
         | 
| 89 89 | 
             
            extra_rdoc_files: []
         | 
| 90 90 | 
             
            files:
         | 
| 91 | 
            -
            -  | 
| 91 | 
            +
            - LICENSE
         | 
| 92 | 
            +
            - README.md
         | 
| 93 | 
            +
            - Rakefile
         | 
| 94 | 
            +
            - lib/repia.rb
         | 
| 95 | 
            +
            - lib/repia/base_controller.rb
         | 
| 96 | 
            +
            - lib/repia/base_helper.rb
         | 
| 92 97 | 
             
            - lib/repia/errors.rb
         | 
| 93 98 | 
             
            - lib/repia/middlewares.rb
         | 
| 99 | 
            +
            - lib/repia/uuid_model.rb
         | 
| 94 100 | 
             
            - lib/repia/version.rb
         | 
| 95 | 
            -
            - lib/repia.rb
         | 
| 96 101 | 
             
            - lib/tasks/repia_tasks.rake
         | 
| 97 | 
            -
            -  | 
| 102 | 
            +
            - test/dummy/README.rdoc
         | 
| 103 | 
            +
            - test/dummy/Rakefile
         | 
| 98 104 | 
             
            - test/dummy/app/assets/javascripts/application.js
         | 
| 99 105 | 
             
            - test/dummy/app/assets/javascripts/dummies.js
         | 
| 100 106 | 
             
            - test/dummy/app/assets/stylesheets/application.css
         | 
| 101 107 | 
             
            - test/dummy/app/assets/stylesheets/dummies.css
         | 
| 102 108 | 
             
            - test/dummy/app/controllers/application_controller.rb
         | 
| 103 | 
            -
            - test/dummy/app/controllers/dummies_controller.rb
         | 
| 104 109 | 
             
            - test/dummy/app/helpers/application_helper.rb
         | 
| 105 110 | 
             
            - test/dummy/app/helpers/dummies_helper.rb
         | 
| 106 111 | 
             
            - test/dummy/app/models/unique_model.rb
         | 
| @@ -109,6 +114,7 @@ files: | |
| 109 114 | 
             
            - test/dummy/bin/rails
         | 
| 110 115 | 
             
            - test/dummy/bin/rake
         | 
| 111 116 | 
             
            - test/dummy/bin/setup
         | 
| 117 | 
            +
            - test/dummy/config.ru
         | 
| 112 118 | 
             
            - test/dummy/config/application.rb
         | 
| 113 119 | 
             
            - test/dummy/config/boot.rb
         | 
| 114 120 | 
             
            - test/dummy/config/database.yml
         | 
| @@ -127,23 +133,22 @@ files: | |
| 127 133 | 
             
            - test/dummy/config/locales/en.yml
         | 
| 128 134 | 
             
            - test/dummy/config/routes.rb
         | 
| 129 135 | 
             
            - test/dummy/config/secrets.yml
         | 
| 130 | 
            -
            - test/dummy/config.ru
         | 
| 131 136 | 
             
            - test/dummy/db/development.sqlite3
         | 
| 132 137 | 
             
            - test/dummy/db/migrate/20160423030023_create_unique_models.rb
         | 
| 133 138 | 
             
            - test/dummy/db/schema.rb
         | 
| 134 139 | 
             
            - test/dummy/db/test.sqlite3
         | 
| 135 | 
            -
            - test/dummy/log/development.log
         | 
| 136 140 | 
             
            - test/dummy/log/test.log
         | 
| 137 141 | 
             
            - test/dummy/public/404.html
         | 
| 138 142 | 
             
            - test/dummy/public/422.html
         | 
| 139 143 | 
             
            - test/dummy/public/500.html
         | 
| 140 144 | 
             
            - test/dummy/public/favicon.ico
         | 
| 141 | 
            -
            - test/dummy/Rakefile
         | 
| 142 | 
            -
            - test/dummy/README.rdoc
         | 
| 143 145 | 
             
            - test/dummy/test/controllers/dummies_controller_test.rb
         | 
| 144 146 | 
             
            - test/dummy/test/fixtures/unique_models.yml
         | 
| 145 147 | 
             
            - test/dummy/test/models/unique_model_test.rb
         | 
| 148 | 
            +
            - test/repia_base_controller_test.rb
         | 
| 149 | 
            +
            - test/repia_middlewares_test.rb
         | 
| 146 150 | 
             
            - test/repia_test.rb
         | 
| 151 | 
            +
            - test/repia_unique_model_test.rb
         | 
| 147 152 | 
             
            - test/test_helper.rb
         | 
| 148 153 | 
             
            homepage: https://github.com/davidan1981/repia
         | 
| 149 154 | 
             
            licenses:
         | 
| @@ -155,17 +160,17 @@ require_paths: | |
| 155 160 | 
             
            - lib
         | 
| 156 161 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 157 162 | 
             
              requirements:
         | 
| 158 | 
            -
              - -  | 
| 163 | 
            +
              - - ">="
         | 
| 159 164 | 
             
                - !ruby/object:Gem::Version
         | 
| 160 165 | 
             
                  version: '0'
         | 
| 161 166 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 162 167 | 
             
              requirements:
         | 
| 163 | 
            -
              - -  | 
| 168 | 
            +
              - - ">="
         | 
| 164 169 | 
             
                - !ruby/object:Gem::Version
         | 
| 165 170 | 
             
                  version: '0'
         | 
| 166 171 | 
             
            requirements: []
         | 
| 167 172 | 
             
            rubyforge_project: 
         | 
| 168 | 
            -
            rubygems_version: 2. | 
| 173 | 
            +
            rubygems_version: 2.5.1
         | 
| 169 174 | 
             
            signing_key: 
         | 
| 170 175 | 
             
            specification_version: 4
         | 
| 171 176 | 
             
            summary: Rails Essential Plug-in for API
         | 
| @@ -175,7 +180,6 @@ test_files: | |
| 175 180 | 
             
            - test/dummy/app/assets/stylesheets/application.css
         | 
| 176 181 | 
             
            - test/dummy/app/assets/stylesheets/dummies.css
         | 
| 177 182 | 
             
            - test/dummy/app/controllers/application_controller.rb
         | 
| 178 | 
            -
            - test/dummy/app/controllers/dummies_controller.rb
         | 
| 179 183 | 
             
            - test/dummy/app/helpers/application_helper.rb
         | 
| 180 184 | 
             
            - test/dummy/app/helpers/dummies_helper.rb
         | 
| 181 185 | 
             
            - test/dummy/app/models/unique_model.rb
         | 
| @@ -207,7 +211,6 @@ test_files: | |
| 207 211 | 
             
            - test/dummy/db/migrate/20160423030023_create_unique_models.rb
         | 
| 208 212 | 
             
            - test/dummy/db/schema.rb
         | 
| 209 213 | 
             
            - test/dummy/db/test.sqlite3
         | 
| 210 | 
            -
            - test/dummy/log/development.log
         | 
| 211 214 | 
             
            - test/dummy/log/test.log
         | 
| 212 215 | 
             
            - test/dummy/public/404.html
         | 
| 213 216 | 
             
            - test/dummy/public/422.html
         | 
| @@ -218,5 +221,8 @@ test_files: | |
| 218 221 | 
             
            - test/dummy/test/controllers/dummies_controller_test.rb
         | 
| 219 222 | 
             
            - test/dummy/test/fixtures/unique_models.yml
         | 
| 220 223 | 
             
            - test/dummy/test/models/unique_model_test.rb
         | 
| 224 | 
            +
            - test/repia_base_controller_test.rb
         | 
| 225 | 
            +
            - test/repia_middlewares_test.rb
         | 
| 221 226 | 
             
            - test/repia_test.rb
         | 
| 227 | 
            +
            - test/repia_unique_model_test.rb
         | 
| 222 228 | 
             
            - test/test_helper.rb
         | 
| @@ -1,36 +0,0 @@ | |
| 1 | 
            -
            class DummiesController < ApplicationController
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              def index
         | 
| 4 | 
            -
                render_errors 400, ["one", "two"]
         | 
| 5 | 
            -
              end
         | 
| 6 | 
            -
             | 
| 7 | 
            -
              def create
         | 
| 8 | 
            -
                1 + "b"
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              def update
         | 
| 12 | 
            -
                find_object(UniqueModel, params[:id])
         | 
| 13 | 
            -
                render json: "", status: 200
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              def show
         | 
| 17 | 
            -
                status_code = params[:id].to_i
         | 
| 18 | 
            -
                case status_code
         | 
| 19 | 
            -
                when 400
         | 
| 20 | 
            -
                  raise Repia::Errors::BadRequest
         | 
| 21 | 
            -
                when 401
         | 
| 22 | 
            -
                  raise Repia::Errors::Unauthorized
         | 
| 23 | 
            -
                when 404
         | 
| 24 | 
            -
                  raise Repia::Errors::NotFound
         | 
| 25 | 
            -
                when 409
         | 
| 26 | 
            -
                  raise Repia::Errors::Conflict
         | 
| 27 | 
            -
                when 500
         | 
| 28 | 
            -
                  raise Repia::Errors::InternalServerError
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
              end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
              def destroy
         | 
| 33 | 
            -
                @exception = ActionController::RoutingError.new("blah")
         | 
| 34 | 
            -
                exceptions_app
         | 
| 35 | 
            -
              end
         | 
| 36 | 
            -
            end
         |