├── .gitattributes ├── .github └── workflows │ ├── rubocop.yml │ └── test.yml ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .rubocop_todo.yml ├── .ruby-version ├── Appraisals ├── Gemfile ├── Gemfile.lock ├── README.md ├── Rakefile ├── app ├── api │ ├── acme │ │ ├── headers.rb │ │ ├── ping.rb │ │ ├── post.rb │ │ ├── protected.rb │ │ └── raise.rb │ └── api.rb ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ └── stylesheets │ │ └── application.css ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ └── welcome_controller.rb ├── helpers │ ├── application_helper.rb │ └── welcome_helper.rb ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ └── concerns │ │ └── .keep └── views │ ├── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ └── mailer.text.erb │ └── welcome │ └── index.html.erb ├── bin ├── rails ├── rake └── setup ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── credentials.yml.enc ├── database.gha.yml ├── database.yml ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── assets.rb │ ├── content_security_policy.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ └── permissions_policy.rb ├── locales │ └── en.yml ├── puma.rb ├── routes.rb └── storage.yml ├── db └── seeds.rb ├── gemfiles ├── rails_6.gemfile ├── rails_6_1.gemfile ├── rails_7.gemfile └── rails_edge.gemfile ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── log └── .keep ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico ├── robots.txt └── swagger │ └── index.html ├── spec ├── api │ ├── headers_spec.rb │ ├── ping_spec.rb │ ├── post_spec.rb │ ├── protected_spec.rb │ └── raise_spec.rb ├── controllers │ └── welcome_controller_spec.rb ├── features │ ├── homepage_spec.rb │ └── swagger_spec.rb ├── helpers │ └── welcome_helper_spec.rb └── spec_helper.rb ├── storage └── .keep ├── tmp ├── .keep ├── pids │ └── .keep └── storage │ └── .keep └── vendor └── .keep /.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark any vendored files as having been vendored. 7 | vendor/* linguist-vendored 8 | -------------------------------------------------------------------------------- /.github/workflows/rubocop.yml: -------------------------------------------------------------------------------- 1 | name: Rubocop 2 | on: [push, pull_request] 3 | jobs: 4 | lint: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@v3 8 | - name: Set up Ruby 9 | uses: ruby/setup-ruby@v1 10 | with: 11 | ruby-version: '3.4' 12 | bundler-cache: true 13 | - run: bundle exec rubocop 14 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: [push, pull_request] 3 | jobs: 4 | test: 5 | runs-on: ubuntu-latest 6 | env: 7 | RAILS_ENV: test 8 | DATABASE_URL: postgres://test:password@127.0.0.1:5432/grape_on_rails_test 9 | BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile.file }}.gemfile 10 | strategy: 11 | fail-fast: false 12 | matrix: 13 | gemfile: 14 | - { ruby: '2.7', file: rails_6 } 15 | - { ruby: '3.0', file: rails_6_1 } 16 | - { ruby: '3.1', file: rails_7 } 17 | - { ruby: '3.2', file: rails_7 } 18 | - { ruby: '3.3', file: rails_7 } 19 | - { ruby: '3.4', file: rails_7 } 20 | # - { ruby: '3.2' ,file: rails_edge } 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Set up Ruby 24 | uses: ruby/setup-ruby@v1 25 | with: 26 | ruby-version: ${{ matrix.entry.ruby }} 27 | bundler-cache: true 28 | - name: Setup Firefox 29 | uses: browser-actions/setup-firefox@latest 30 | with: 31 | firefox-version: "134.0.1" 32 | - uses: browser-actions/setup-geckodriver@latest 33 | with: 34 | geckodriver-version: "0.32.2" 35 | - name: Setup database configuration 36 | run: cp config/database.gha.yml config/database.yml 37 | - uses: harmon758/postgresql-action@v1 38 | with: 39 | postgresql version: "14" 40 | postgresql db: grape_on_rails_test 41 | postgresql user: test 42 | postgresql password: password 43 | - uses: coactions/setup-xvfb@v1 44 | with: 45 | run: | 46 | bundle exec rake db:create 47 | bundle exec rake spec 48 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | # Ignore pidfiles, but keep the directory. 17 | /tmp/pids/* 18 | !/tmp/pids/ 19 | !/tmp/pids/.keep 20 | 21 | # Ignore uploaded files in development. 22 | /storage/* 23 | !/storage/.keep 24 | /tmp/storage/* 25 | !/tmp/storage/ 26 | !/tmp/storage/.keep 27 | 28 | /public/assets 29 | 30 | # Ignore master key for decrypting credentials and more. 31 | /config/master.key 32 | 33 | # Appraisal gem 34 | .bundle 35 | /gemfiles/*.lock 36 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --color 2 | --format=documentation 3 | 4 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - vendor/**/* 4 | - bin/**/* 5 | NewCops: enable 6 | 7 | Style/Documentation: 8 | Enabled: false 9 | 10 | Style/FrozenStringLiteralComment: 11 | Enabled: false 12 | 13 | Layout/LineLength: 14 | Enabled: false 15 | 16 | require: 17 | - rubocop-capybara 18 | - rubocop-rails 19 | - rubocop-rspec_rails 20 | - rubocop-rake 21 | - rubocop-rspec 22 | 23 | inherit_from: .rubocop_todo.yml 24 | -------------------------------------------------------------------------------- /.rubocop_todo.yml: -------------------------------------------------------------------------------- 1 | # This configuration was generated by 2 | # `rubocop --auto-gen-config` 3 | # on 2025-02-20 15:23:50 UTC using RuboCop version 1.62.1. 4 | # The point is for the user to remove these configuration records 5 | # one by one as the offenses are removed from the code base. 6 | # Note that changes in the inspected code, or installation of new 7 | # versions of RuboCop, may require this file to be generated again. 8 | 9 | # Offense count: 1 10 | # Configuration parameters: AllowComments, AllowEmptyLambdas. 11 | Lint/EmptyBlock: 12 | Exclude: 13 | - 'spec/helpers/welcome_helper_spec.rb' 14 | 15 | # Offense count: 1 16 | # This cop supports unsafe autocorrection (--autocorrect-all). 17 | # Configuration parameters: AutoCorrect. 18 | RSpec/EmptyExampleGroup: 19 | Exclude: 20 | - 'spec/helpers/welcome_helper_spec.rb' 21 | 22 | # Offense count: 4 23 | # Configuration parameters: CountAsOne. 24 | RSpec/ExampleLength: 25 | Max: 22 26 | 27 | # Offense count: 6 28 | RSpec/MultipleExpectations: 29 | Max: 2 30 | 31 | # Offense count: 2 32 | RSpec/RepeatedExample: 33 | Exclude: 34 | - 'spec/api/headers_spec.rb' 35 | 36 | # Offense count: 5 37 | # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. 38 | # Include: **/*_spec.rb 39 | RSpec/SpecFilePathFormat: 40 | Exclude: 41 | - 'spec/api/headers_spec.rb' 42 | - 'spec/api/ping_spec.rb' 43 | - 'spec/api/post_spec.rb' 44 | - 'spec/api/protected_spec.rb' 45 | - 'spec/api/raise_spec.rb' 46 | 47 | # Offense count: 4 48 | # This cop supports unsafe autocorrection (--autocorrect-all). 49 | # Configuration parameters: ResponseMethods. 50 | # ResponseMethods: response, last_response 51 | RSpecRails/HaveHttpStatus: 52 | Exclude: 53 | - 'spec/api/post_spec.rb' 54 | - 'spec/api/protected_spec.rb' 55 | 56 | # Offense count: 2 57 | # This cop supports unsafe autocorrection (--autocorrect-all). 58 | # Configuration parameters: Inferences. 59 | RSpecRails/InferredSpecType: 60 | Exclude: 61 | - 'spec/features/homepage_spec.rb' 62 | - 'spec/features/swagger_spec.rb' 63 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | 3.1.2 2 | -------------------------------------------------------------------------------- /Appraisals: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | appraise 'rails-6' do 4 | gem 'rails', '~> 6.0' 5 | end 6 | 7 | appraise 'rails-6-1' do 8 | gem 'rails', '~> 6.1' 9 | end 10 | 11 | appraise 'rails-7' do 12 | gem 'rails', '~> 7.0' 13 | end 14 | 15 | appraise 'rails-edge' do 16 | gem 'rails', github: 'rails/rails' 17 | end 18 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | # https://stackoverflow.com/questions/79360526/uninitialized-constant-activesupportloggerthreadsafelevellogger-nameerror 5 | gem 'concurrent-ruby', '1.3.4' 6 | 7 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" 8 | gem 'rails', '~> 7.0.8' 9 | 10 | # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] 11 | gem 'sprockets-rails' 12 | 13 | # Use postgresql as the database for Active Record 14 | gem 'pg', '~> 1.1' 15 | 16 | # Use the Puma web server [https://github.com/puma/puma] 17 | gem 'puma' 18 | 19 | # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] 20 | gem 'importmap-rails' 21 | 22 | # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] 23 | gem 'turbo-rails' 24 | 25 | # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] 26 | gem 'stimulus-rails' 27 | 28 | # Build JSON APIs with ease [https://github.com/rails/jbuilder] 29 | gem 'jbuilder' 30 | 31 | # Use Redis adapter to run Action Cable in production 32 | # gem "redis", "~> 4.0" 33 | 34 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] 35 | # gem "kredis" 36 | 37 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] 38 | # gem "bcrypt", "~> 3.1.7" 39 | 40 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 41 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] 42 | 43 | # Reduces boot times through caching; required in config/boot.rb 44 | gem 'bootsnap', require: false 45 | 46 | # Use Sass to process CSS 47 | # gem "sassc-rails" 48 | 49 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] 50 | # gem "image_processing", "~> 1.2" 51 | 52 | gem 'grape', '~> 2.1' 53 | gem 'grape-swagger' 54 | 55 | group :development, :test do 56 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem 57 | gem 'debug', platforms: %i[mri mingw x64_mingw] 58 | end 59 | 60 | group :development do 61 | gem 'appraisal' 62 | 63 | # Use console on exceptions pages [https://github.com/rails/web-console] 64 | gem 'web-console' 65 | 66 | # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] 67 | # gem "rack-mini-profiler" 68 | 69 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring] 70 | # gem "spring" 71 | end 72 | 73 | group :test do 74 | # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] 75 | gem 'capybara' 76 | gem 'rspec' 77 | gem 'rspec-rails' 78 | gem 'rubocop', '1.62.1' 79 | gem 'rubocop-capybara' 80 | gem 'rubocop-rails' 81 | gem 'rubocop-rake' 82 | gem 'rubocop-rspec' 83 | gem 'rubocop-rspec_rails' 84 | gem 'selenium-webdriver', '4.20' 85 | end 86 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (7.0.8.7) 5 | actionpack (= 7.0.8.7) 6 | activesupport (= 7.0.8.7) 7 | nio4r (~> 2.0) 8 | websocket-driver (>= 0.6.1) 9 | actionmailbox (7.0.8.7) 10 | actionpack (= 7.0.8.7) 11 | activejob (= 7.0.8.7) 12 | activerecord (= 7.0.8.7) 13 | activestorage (= 7.0.8.7) 14 | activesupport (= 7.0.8.7) 15 | mail (>= 2.7.1) 16 | net-imap 17 | net-pop 18 | net-smtp 19 | actionmailer (7.0.8.7) 20 | actionpack (= 7.0.8.7) 21 | actionview (= 7.0.8.7) 22 | activejob (= 7.0.8.7) 23 | activesupport (= 7.0.8.7) 24 | mail (~> 2.5, >= 2.5.4) 25 | net-imap 26 | net-pop 27 | net-smtp 28 | rails-dom-testing (~> 2.0) 29 | actionpack (7.0.8.7) 30 | actionview (= 7.0.8.7) 31 | activesupport (= 7.0.8.7) 32 | rack (~> 2.0, >= 2.2.4) 33 | rack-test (>= 0.6.3) 34 | rails-dom-testing (~> 2.0) 35 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 36 | actiontext (7.0.8.7) 37 | actionpack (= 7.0.8.7) 38 | activerecord (= 7.0.8.7) 39 | activestorage (= 7.0.8.7) 40 | activesupport (= 7.0.8.7) 41 | globalid (>= 0.6.0) 42 | nokogiri (>= 1.8.5) 43 | actionview (7.0.8.7) 44 | activesupport (= 7.0.8.7) 45 | builder (~> 3.1) 46 | erubi (~> 1.4) 47 | rails-dom-testing (~> 2.0) 48 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 49 | activejob (7.0.8.7) 50 | activesupport (= 7.0.8.7) 51 | globalid (>= 0.3.6) 52 | activemodel (7.0.8.7) 53 | activesupport (= 7.0.8.7) 54 | activerecord (7.0.8.7) 55 | activemodel (= 7.0.8.7) 56 | activesupport (= 7.0.8.7) 57 | activestorage (7.0.8.7) 58 | actionpack (= 7.0.8.7) 59 | activejob (= 7.0.8.7) 60 | activerecord (= 7.0.8.7) 61 | activesupport (= 7.0.8.7) 62 | marcel (~> 1.0) 63 | mini_mime (>= 1.1.0) 64 | activesupport (7.0.8.7) 65 | concurrent-ruby (~> 1.0, >= 1.0.2) 66 | i18n (>= 1.6, < 2) 67 | minitest (>= 5.1) 68 | tzinfo (~> 2.0) 69 | addressable (2.8.7) 70 | public_suffix (>= 2.0.2, < 7.0) 71 | appraisal (2.5.0) 72 | bundler 73 | rake 74 | thor (>= 0.14.0) 75 | ast (2.4.2) 76 | base64 (0.2.0) 77 | bigdecimal (3.1.9) 78 | bindex (0.8.1) 79 | bootsnap (1.18.4) 80 | msgpack (~> 1.2) 81 | builder (3.3.0) 82 | capybara (3.40.0) 83 | addressable 84 | matrix 85 | mini_mime (>= 0.1.3) 86 | nokogiri (~> 1.11) 87 | rack (>= 1.6.0) 88 | rack-test (>= 0.6.3) 89 | regexp_parser (>= 1.5, < 3.0) 90 | xpath (~> 3.2) 91 | concurrent-ruby (1.3.4) 92 | crass (1.0.6) 93 | date (3.4.1) 94 | debug (1.10.0) 95 | irb (~> 1.10) 96 | reline (>= 0.3.8) 97 | diff-lcs (1.6.0) 98 | dry-core (1.1.0) 99 | concurrent-ruby (~> 1.0) 100 | logger 101 | zeitwerk (~> 2.6) 102 | dry-inflector (1.2.0) 103 | dry-logic (1.6.0) 104 | bigdecimal 105 | concurrent-ruby (~> 1.0) 106 | dry-core (~> 1.1) 107 | zeitwerk (~> 2.6) 108 | dry-types (1.8.2) 109 | bigdecimal (~> 3.0) 110 | concurrent-ruby (~> 1.0) 111 | dry-core (~> 1.0) 112 | dry-inflector (~> 1.0) 113 | dry-logic (~> 1.4) 114 | zeitwerk (~> 2.6) 115 | erubi (1.13.1) 116 | globalid (1.2.1) 117 | activesupport (>= 6.1) 118 | grape (2.3.0) 119 | activesupport (>= 6) 120 | dry-types (>= 1.1) 121 | mustermann-grape (~> 1.1.0) 122 | rack (>= 2) 123 | zeitwerk 124 | grape-swagger (2.1.2) 125 | grape (>= 1.7, < 3.0) 126 | rack-test (~> 2) 127 | i18n (1.14.7) 128 | concurrent-ruby (~> 1.0) 129 | importmap-rails (2.1.0) 130 | actionpack (>= 6.0.0) 131 | activesupport (>= 6.0.0) 132 | railties (>= 6.0.0) 133 | io-console (0.8.0) 134 | irb (1.15.1) 135 | pp (>= 0.6.0) 136 | rdoc (>= 4.0.0) 137 | reline (>= 0.4.2) 138 | jbuilder (2.13.0) 139 | actionview (>= 5.0.0) 140 | activesupport (>= 5.0.0) 141 | json (2.10.1) 142 | language_server-protocol (3.17.0.4) 143 | logger (1.6.6) 144 | loofah (2.24.0) 145 | crass (~> 1.0.2) 146 | nokogiri (>= 1.12.0) 147 | mail (2.8.1) 148 | mini_mime (>= 0.1.1) 149 | net-imap 150 | net-pop 151 | net-smtp 152 | marcel (1.0.4) 153 | matrix (0.4.2) 154 | method_source (1.1.0) 155 | mini_mime (1.1.5) 156 | mini_portile2 (2.8.8) 157 | minitest (5.25.4) 158 | msgpack (1.8.0) 159 | mustermann (3.0.3) 160 | ruby2_keywords (~> 0.0.1) 161 | mustermann-grape (1.1.0) 162 | mustermann (>= 1.0.0) 163 | net-imap (0.5.7) 164 | date 165 | net-protocol 166 | net-pop (0.1.2) 167 | net-protocol 168 | net-protocol (0.2.2) 169 | timeout 170 | net-smtp (0.5.1) 171 | net-protocol 172 | nio4r (2.7.4) 173 | nokogiri (1.18.8) 174 | mini_portile2 (~> 2.8.2) 175 | racc (~> 1.4) 176 | parallel (1.26.3) 177 | parser (3.3.7.1) 178 | ast (~> 2.4.1) 179 | racc 180 | pg (1.5.9) 181 | pp (0.6.2) 182 | prettyprint 183 | prettyprint (0.2.0) 184 | psych (5.2.3) 185 | date 186 | stringio 187 | public_suffix (6.0.1) 188 | puma (6.6.0) 189 | nio4r (~> 2.0) 190 | racc (1.8.1) 191 | rack (2.2.14) 192 | rack-test (2.2.0) 193 | rack (>= 1.3) 194 | rails (7.0.8.7) 195 | actioncable (= 7.0.8.7) 196 | actionmailbox (= 7.0.8.7) 197 | actionmailer (= 7.0.8.7) 198 | actionpack (= 7.0.8.7) 199 | actiontext (= 7.0.8.7) 200 | actionview (= 7.0.8.7) 201 | activejob (= 7.0.8.7) 202 | activemodel (= 7.0.8.7) 203 | activerecord (= 7.0.8.7) 204 | activestorage (= 7.0.8.7) 205 | activesupport (= 7.0.8.7) 206 | bundler (>= 1.15.0) 207 | railties (= 7.0.8.7) 208 | rails-dom-testing (2.2.0) 209 | activesupport (>= 5.0.0) 210 | minitest 211 | nokogiri (>= 1.6) 212 | rails-html-sanitizer (1.6.2) 213 | loofah (~> 2.21) 214 | nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) 215 | railties (7.0.8.7) 216 | actionpack (= 7.0.8.7) 217 | activesupport (= 7.0.8.7) 218 | method_source 219 | rake (>= 12.2) 220 | thor (~> 1.0) 221 | zeitwerk (~> 2.5) 222 | rainbow (3.1.1) 223 | rake (13.2.1) 224 | rdoc (6.12.0) 225 | psych (>= 4.0.0) 226 | regexp_parser (2.10.0) 227 | reline (0.6.0) 228 | io-console (~> 0.5) 229 | rexml (3.4.1) 230 | rspec (3.13.0) 231 | rspec-core (~> 3.13.0) 232 | rspec-expectations (~> 3.13.0) 233 | rspec-mocks (~> 3.13.0) 234 | rspec-core (3.13.3) 235 | rspec-support (~> 3.13.0) 236 | rspec-expectations (3.13.3) 237 | diff-lcs (>= 1.2.0, < 2.0) 238 | rspec-support (~> 3.13.0) 239 | rspec-mocks (3.13.2) 240 | diff-lcs (>= 1.2.0, < 2.0) 241 | rspec-support (~> 3.13.0) 242 | rspec-rails (7.1.1) 243 | actionpack (>= 7.0) 244 | activesupport (>= 7.0) 245 | railties (>= 7.0) 246 | rspec-core (~> 3.13) 247 | rspec-expectations (~> 3.13) 248 | rspec-mocks (~> 3.13) 249 | rspec-support (~> 3.13) 250 | rspec-support (3.13.2) 251 | rubocop (1.62.1) 252 | json (~> 2.3) 253 | language_server-protocol (>= 3.17.0) 254 | parallel (~> 1.10) 255 | parser (>= 3.3.0.2) 256 | rainbow (>= 2.2.2, < 4.0) 257 | regexp_parser (>= 1.8, < 3.0) 258 | rexml (>= 3.2.5, < 4.0) 259 | rubocop-ast (>= 1.31.1, < 2.0) 260 | ruby-progressbar (~> 1.7) 261 | unicode-display_width (>= 2.4.0, < 3.0) 262 | rubocop-ast (1.38.0) 263 | parser (>= 3.3.1.0) 264 | rubocop-capybara (2.21.0) 265 | rubocop (~> 1.41) 266 | rubocop-rails (2.29.1) 267 | activesupport (>= 4.2.0) 268 | rack (>= 1.1) 269 | rubocop (>= 1.52.0, < 2.0) 270 | rubocop-ast (>= 1.31.1, < 2.0) 271 | rubocop-rake (0.6.0) 272 | rubocop (~> 1.0) 273 | rubocop-rspec (3.4.0) 274 | rubocop (~> 1.61) 275 | rubocop-rspec_rails (2.30.0) 276 | rubocop (~> 1.61) 277 | rubocop-rspec (~> 3, >= 3.0.1) 278 | ruby-progressbar (1.13.0) 279 | ruby2_keywords (0.0.5) 280 | rubyzip (2.4.1) 281 | selenium-webdriver (4.20.0) 282 | base64 (~> 0.2) 283 | rexml (~> 3.2, >= 3.2.5) 284 | rubyzip (>= 1.2.2, < 3.0) 285 | websocket (~> 1.0) 286 | sprockets (4.2.1) 287 | concurrent-ruby (~> 1.0) 288 | rack (>= 2.2.4, < 4) 289 | sprockets-rails (3.5.2) 290 | actionpack (>= 6.1) 291 | activesupport (>= 6.1) 292 | sprockets (>= 3.0.0) 293 | stimulus-rails (1.3.4) 294 | railties (>= 6.0.0) 295 | stringio (3.1.4) 296 | thor (1.3.2) 297 | timeout (0.4.3) 298 | turbo-rails (2.0.11) 299 | actionpack (>= 6.0.0) 300 | railties (>= 6.0.0) 301 | tzinfo (2.0.6) 302 | concurrent-ruby (~> 1.0) 303 | unicode-display_width (2.6.0) 304 | web-console (4.2.1) 305 | actionview (>= 6.0.0) 306 | activemodel (>= 6.0.0) 307 | bindex (>= 0.4.0) 308 | railties (>= 6.0.0) 309 | websocket (1.2.11) 310 | websocket-driver (0.7.7) 311 | base64 312 | websocket-extensions (>= 0.1.0) 313 | websocket-extensions (0.1.5) 314 | xpath (3.2.0) 315 | nokogiri (~> 1.8) 316 | zeitwerk (2.7.2) 317 | 318 | PLATFORMS 319 | ruby 320 | 321 | DEPENDENCIES 322 | appraisal 323 | bootsnap 324 | capybara 325 | concurrent-ruby (= 1.3.4) 326 | debug 327 | grape (~> 2.1) 328 | grape-swagger 329 | importmap-rails 330 | jbuilder 331 | pg (~> 1.1) 332 | puma 333 | rails (~> 7.0.8) 334 | rspec 335 | rspec-rails 336 | rubocop (= 1.62.1) 337 | rubocop-capybara 338 | rubocop-rails 339 | rubocop-rake 340 | rubocop-rspec 341 | rubocop-rspec_rails 342 | selenium-webdriver (= 4.20) 343 | sprockets-rails 344 | stimulus-rails 345 | turbo-rails 346 | tzinfo-data 347 | web-console 348 | 349 | BUNDLED WITH 350 | 2.5.2 351 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Grape on Rails 2 | 3 | [![Test](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml) 4 | [![Rubocop](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/ruby-grape/grape-on-rails/actions/workflows/test.yml) 5 | [![Code Climate](https://codeclimate.com/github/ruby-grape/grape-on-rails.svg)](https://codeclimate.com/github/ruby-grape/grape-on-rails) 6 | 7 | A [Grape](http://github.com/ruby-grape/grape) API mounted on Rails. 8 | 9 | - [ping](app/api/acme/ping.rb): a hello world `GET` API 10 | - [post](app/api/acme/post.rb): post JSON data 11 | - [raise](app/api/acme/raise.rb): raise an error, Rails handling exceptions 12 | - [protected](app/api/acme/protected.rb): API protected with rudimentary Basic Authentication 13 | - [headers](app/api/acme/headers.rb): demonstrates header handling 14 | 15 | ## Run 16 | 17 | ``` 18 | bin/setup 19 | rails s 20 | ``` 21 | 22 | - Try http://localhost:3000/api/ping or http://localhost:3000/api/protected/ping with _username_ and _password_. 23 | - View Swagger docs at http://localhost:3000/swagger. 24 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | 8 | if Rails.env.test? || Rails.env.development? 9 | require 'rspec/core/rake_task' 10 | 11 | Rake::Task[:default].prerequisites.clear 12 | 13 | require 'rubocop/rake_task' 14 | RuboCop::RakeTask.new(:rubocop) 15 | 16 | task default: %i[rubocop spec] 17 | end 18 | -------------------------------------------------------------------------------- /app/api/acme/headers.rb: -------------------------------------------------------------------------------- 1 | module Acme 2 | class Headers < Grape::API 3 | format :json 4 | 5 | namespace :headers do 6 | desc 'Returns a header value.' 7 | params do 8 | requires :key, type: String 9 | end 10 | get ':key' do 11 | key = params[:key] 12 | { key => headers[key] } 13 | end 14 | 15 | desc 'Returns all headers.' 16 | get do 17 | headers 18 | end 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /app/api/acme/ping.rb: -------------------------------------------------------------------------------- 1 | module Acme 2 | class Ping < Grape::API 3 | desc 'Returns pong.' 4 | get :ping do 5 | { ping: params[:pong] || 'pong' } 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /app/api/acme/post.rb: -------------------------------------------------------------------------------- 1 | module Acme 2 | class Post < Grape::API 3 | desc 'Creates a spline that can be reticulated.' 4 | params do 5 | optional :reticulated, type: Boolean, documentation: { param_type: 'body' } 6 | end 7 | resource :spline do 8 | post do 9 | { reticulated: params[:reticulated] } 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/api/acme/protected.rb: -------------------------------------------------------------------------------- 1 | module Acme 2 | class Protected < Grape::API 3 | namespace :protected do 4 | http_basic do |username, password| 5 | username == 'username' && password == 'password' 6 | end 7 | desc 'Returns pong if username=username and password=password.' 8 | get :ping do 9 | { ping: 'pong' } 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/api/acme/raise.rb: -------------------------------------------------------------------------------- 1 | module Acme 2 | class Raise < Grape::API 3 | desc 'Raises an exception.' 4 | get :raise do 5 | raise 'Unexpected error.' 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /app/api/api.rb: -------------------------------------------------------------------------------- 1 | class API < Grape::API 2 | prefix 'api' 3 | format :json 4 | mount Acme::Ping 5 | mount Acme::Raise 6 | mount Acme::Protected 7 | mount Acme::Post 8 | mount Acme::Headers 9 | add_swagger_documentation info: { title: 'grape-on-rails' } 10 | end 11 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../stylesheets .css 3 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/welcome_controller.rb: -------------------------------------------------------------------------------- 1 | class WelcomeController < ApplicationController 2 | def index; end 3 | end 4 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/welcome_helper.rb: -------------------------------------------------------------------------------- 1 | module WelcomeHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | if Gem::Version.new(Rails.version) >= Gem::Version.new('7.0') 3 | primary_abstract_class 4 | else 5 | self.abstract_class = true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | GrapeOnRails 5 | 6 | <%= csrf_meta_tags %> 7 | <%= csp_meta_tag %> 8 | 9 | <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> 10 | 11 | 12 | 13 | <%= yield %> 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/views/welcome/index.html.erb: -------------------------------------------------------------------------------- 1 |

Grape Mounted on Rails 7

2 | 6 | Fork me on Github 7 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path("..", __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts "== Installing dependencies ==" 17 | system! "gem install bundler --conservative" 18 | system("bundle check") || system!("bundle install") 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?("config/database.yml") 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! "bin/rails db:prepare" 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! "bin/rails log:clear tmp:clear" 30 | 31 | puts "\n== Restarting application server ==" 32 | system! "bin/rails restart" 33 | end 34 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module GrapeOnRails 10 | class Application < Rails::Application 11 | # Since we're testing against multiple versions, initialize configuration defaults 12 | # based upon the version we're using. 13 | rails_version = Gem::Version.new(Rails.version) 14 | if rails_version >= Gem::Version.new('7.0') 15 | config.load_defaults 7.0 16 | elsif rails_version >= Gem::Version.new('6.1') 17 | config.load_defaults 6.1 18 | else 19 | config.load_defaults 6.0 20 | end 21 | # Configuration for the application, engines, and railties goes here. 22 | # 23 | # These settings can be overridden in specific environments using the files 24 | # in config/environments, which are processed later. 25 | # 26 | # config.time_zone = "Central Time (US & Canada)" 27 | # config.eager_load_paths << Rails.root.join("extras") 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: rails_test_pg_production 11 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | wkeyk8+juX9vg/BcfcdfaHUzoZfNuS+Ev4tcUinUoClF7GqyQdbTFfoJqs/2vHC7TR8N8sZrz3qj4Z8WJXix5aVYrh8mwpdFg+eX0ngknSs7wll2YZ6r/qNZM1CRIH1xnmrr1lnR5HKv2vW57dJpl+PwLU5ZLfxA1JciC5yj+fvibQ+HJ1aVkMN9QgWWZx13NeGUPSJYGlcwS8CF1io+zq6H/lRJzNBATjlVMlsgk79ogI8KC9AWFHutWU++fuF9K78hUmHI0Xp211vNdGh8/GcpC0xHuR8/GNU66exJ0QjEdYpS3OH2twE4EzBeWd3tJFs2i7nWeWkIaQJYcxRueJEsNQ6l7BvHl6jhVFvve0icHsdPSFQaD1d/LBDMw7iJfJL2dH0ux3w6pN+yac4Oqf1tDEZm1lf8Flm1--SWDdGMfZPHqb6hNs--xXmU7F/8jWluhwwypuYZFg== -------------------------------------------------------------------------------- /config/database.gha.yml: -------------------------------------------------------------------------------- 1 | test: 2 | adapter: postgresql 3 | database: grape_on_rails_test 4 | url: <%= ENV["DATABASE_URL"] %> 5 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 9.3 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On macOS with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On macOS with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem "pg" 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see Rails configuration guide 21 | # https://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 23 | 24 | development: 25 | <<: *default 26 | database: grape_on_rails_development 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user running Rails. 32 | #username: grape_on_rails 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: grape_on_rails_test 61 | 62 | # As with config/credentials.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password or a full connection URL as an environment 67 | # variable when you boot the app. For example: 68 | # 69 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 70 | # 71 | # If the connection URL is provided in the special DATABASE_URL environment 72 | # variable, Rails will automatically merge its configuration values on top of 73 | # the values provided in this file. Alternatively, you can specify a connection 74 | # URL environment variable explicitly: 75 | # 76 | # production: 77 | # url: <%= ENV["MY_APP_DATABASE_URL"] %> 78 | # 79 | # Read https://guides.rubyonrails.org/configuring.html#configuring-a-database 80 | # for a full overview on how database connection configuration can be specified. 81 | # 82 | production: 83 | <<: *default 84 | database: grape_on_rails_production 85 | username: grape_on_rails 86 | password: <%= ENV["grape_on_rails_DATABASE_PASSWORD"] %> 87 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/core_ext/integer/time' 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded any time 7 | # it changes. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.cache_classes = false 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable server timing 18 | config.server_timing = true 19 | 20 | # Enable/disable caching. By default caching is disabled. 21 | # Run rails dev:cache to toggle caching. 22 | if Rails.root.join('tmp/caching-dev.txt').exist? 23 | config.action_controller.perform_caching = true 24 | config.action_controller.enable_fragment_cache_logging = true 25 | 26 | config.cache_store = :memory_store 27 | config.public_file_server.headers = { 28 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 29 | } 30 | else 31 | config.action_controller.perform_caching = false 32 | 33 | config.cache_store = :null_store 34 | end 35 | 36 | # Store uploaded files on the local file system (see config/storage.yml for options). 37 | config.active_storage.service = :local 38 | 39 | # Don't care if the mailer can't send. 40 | config.action_mailer.raise_delivery_errors = false 41 | 42 | config.action_mailer.perform_caching = false 43 | 44 | # Print deprecation notices to the Rails logger. 45 | config.active_support.deprecation = :log 46 | 47 | # Raise exceptions for disallowed deprecations. 48 | config.active_support.disallowed_deprecation = :raise 49 | 50 | # Tell Active Support which deprecation messages to disallow. 51 | config.active_support.disallowed_deprecation_warnings = [] 52 | 53 | # Raise an error on page load if there are pending migrations. 54 | config.active_record.migration_error = :page_load 55 | 56 | # Highlight code that triggered database queries in logs. 57 | config.active_record.verbose_query_logs = true 58 | 59 | # Suppress logger output for asset requests. 60 | config.assets.quiet = true 61 | 62 | # Raises error for missing translations. 63 | # config.i18n.raise_on_missing_translations = true 64 | 65 | # Annotate rendered view with file names. 66 | # config.action_view.annotate_rendered_view_with_filenames = true 67 | 68 | # Uncomment if you wish to allow Action Cable access from any origin. 69 | # config.action_cable.disable_request_forgery_protection = true 70 | end 71 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/core_ext/integer/time' 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Code is not reloaded between requests. 7 | config.cache_classes = true 8 | 9 | # Eager load code on boot. This eager loads most of Rails and 10 | # your application in memory, allowing both threaded web servers 11 | # and those relying on copy on write to perform better. 12 | # Rake tasks automatically ignore this option for performance. 13 | config.eager_load = true 14 | 15 | # Full error reports are disabled and caching is turned on. 16 | config.consider_all_requests_local = false 17 | config.action_controller.perform_caching = true 18 | 19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 21 | # config.require_master_key = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress CSS using a preprocessor. 28 | # config.assets.css_compressor = :sass 29 | 30 | # Do not fallback to assets pipeline if a precompiled asset is missed. 31 | config.assets.compile = false 32 | 33 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 34 | # config.asset_host = "http://assets.example.com" 35 | 36 | # Specifies the header that your server uses for sending files. 37 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache 38 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX 39 | 40 | # Store uploaded files on the local file system (see config/storage.yml for options). 41 | config.active_storage.service = :local 42 | 43 | # Mount Action Cable outside main process or domain. 44 | # config.action_cable.mount_path = nil 45 | # config.action_cable.url = "wss://example.com/cable" 46 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] 47 | 48 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 49 | # config.force_ssl = true 50 | 51 | # Include generic and useful information about system operation, but avoid logging too much 52 | # information to avoid inadvertent exposure of personally identifiable information (PII). 53 | config.log_level = :info 54 | 55 | # Prepend all log lines with the following tags. 56 | config.log_tags = [:request_id] 57 | 58 | # Use a different cache store in production. 59 | # config.cache_store = :mem_cache_store 60 | 61 | # Use a real queuing backend for Active Job (and separate queues per environment). 62 | # config.active_job.queue_adapter = :resque 63 | # config.active_job.queue_name_prefix = "rails_test_pg_production" 64 | 65 | config.action_mailer.perform_caching = false 66 | 67 | # Ignore bad email addresses and do not raise email delivery errors. 68 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 69 | # config.action_mailer.raise_delivery_errors = false 70 | 71 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 72 | # the I18n.default_locale when a translation cannot be found). 73 | config.i18n.fallbacks = true 74 | 75 | # Don't log any deprecations. 76 | config.active_support.report_deprecations = false 77 | 78 | # Use default logging formatter so that PID and timestamp are not suppressed. 79 | config.log_formatter = Logger::Formatter.new 80 | 81 | # Use a different logger for distributed setups. 82 | # require "syslog/logger" 83 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") 84 | 85 | if ENV['RAILS_LOG_TO_STDOUT'].present? 86 | logger = ActiveSupport::Logger.new($stdout) 87 | logger.formatter = config.log_formatter 88 | config.logger = ActiveSupport::TaggedLogging.new(logger) 89 | end 90 | 91 | # Do not dump schema after migrations. 92 | config.active_record.dump_schema_after_migration = false 93 | end 94 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require 'active_support/core_ext/integer/time' 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | # Turn false under Spring and add config.action_view.cache_template_loading = true. 12 | config.cache_classes = true 13 | 14 | # Eager loading loads your whole application. When running a single test locally, 15 | # this probably isn't necessary. It's a good idea to do in a continuous integration 16 | # system, or in some way before deploying your code. 17 | config.eager_load = ENV['CI'].present? 18 | 19 | # Configure public file server for tests with Cache-Control for performance. 20 | config.public_file_server.enabled = true 21 | config.public_file_server.headers = { 22 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 23 | } 24 | 25 | # Show full error reports and disable caching. 26 | config.consider_all_requests_local = true 27 | config.action_controller.perform_caching = false 28 | config.cache_store = :null_store 29 | 30 | # Raise exceptions instead of rendering exception templates. 31 | config.action_dispatch.show_exceptions = if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1') 32 | :none 33 | else 34 | false 35 | end 36 | 37 | # Disable request forgery protection in test environment. 38 | config.action_controller.allow_forgery_protection = false 39 | 40 | # Store uploaded files on the local file system in a temporary directory. 41 | config.active_storage.service = :test 42 | 43 | config.action_mailer.perform_caching = false 44 | 45 | # Tell Action Mailer not to deliver emails to the real world. 46 | # The :test delivery method accumulates sent emails in the 47 | # ActionMailer::Base.deliveries array. 48 | config.action_mailer.delivery_method = :test 49 | 50 | # Print deprecation notices to the stderr. 51 | config.active_support.deprecation = :stderr 52 | 53 | # Raise exceptions for disallowed deprecations. 54 | config.active_support.disallowed_deprecation = :raise 55 | 56 | # Tell Active Support which deprecation messages to disallow. 57 | config.active_support.disallowed_deprecation_warnings = [] 58 | 59 | # Raises error for missing translations. 60 | # config.i18n.raise_on_missing_translations = true 61 | 62 | # Annotate rendered view with file names. 63 | # config.action_view.annotate_rendered_view_with_filenames = true 64 | end 65 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in the app/assets 11 | # folder are already added. 12 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 13 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy. 4 | # See the Securing Rails Applications Guide for more information: 5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header 6 | 7 | # Rails.application.configure do 8 | # config.content_security_policy do |policy| 9 | # policy.default_src :self, :https 10 | # policy.font_src :self, :https, :data 11 | # policy.img_src :self, :https, :data 12 | # policy.object_src :none 13 | # policy.script_src :self, :https 14 | # policy.style_src :self, :https 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | # 19 | # # Generate session nonces for permitted importmap and inline scripts 20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } 21 | # config.content_security_policy_nonce_directives = %w(script-src) 22 | # 23 | # # Report violations without enforcing the policy. 24 | # # config.content_security_policy_report_only = true 25 | # end 26 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of 4 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported 5 | # notations and behaviors. 6 | Rails.application.config.filter_parameters += %i[ 7 | passw secret token _key crypt salt certificate otp ssn 8 | ] 9 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | inflect.acronym 'API' 16 | end 17 | -------------------------------------------------------------------------------- /config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Define an application-wide HTTP permissions policy. For further 2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy 3 | # 4 | # Rails.application.config.permissions_policy do |f| 5 | # f.camera :none 6 | # f.gyroscope :none 7 | # f.microphone :none 8 | # f.usb :none 9 | # f.fullscreen :self 10 | # f.payment :self, "https://secure.example.com" 11 | # end 12 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # "true": "foo" 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5) 8 | min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 12 | # terminating a worker in development environments. 13 | # 14 | worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development' 15 | 16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 17 | # 18 | port ENV.fetch('PORT', 3000) 19 | 20 | # Specifies the `environment` that Puma will run in. 21 | # 22 | environment ENV.fetch('RAILS_ENV') { 'development' } 23 | 24 | # Specifies the `pidfile` that Puma will use. 25 | pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' } 26 | 27 | # Specifies the number of `workers` to boot in clustered mode. 28 | # Workers are forked web server processes. If using threads and workers together 29 | # the concurrency of the application would be max `threads` * `workers`. 30 | # Workers do not work on JRuby or Windows (both of which do not support 31 | # processes). 32 | # 33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 34 | 35 | # Use the `preload_app!` method when specifying a `workers` number. 36 | # This directive tells Puma to first boot the application and load code 37 | # before forking the application. This takes advantage of Copy On Write 38 | # process behavior so workers use less memory. 39 | # 40 | # preload_app! 41 | 42 | # Allow puma to be restarted by `bin/rails restart` command. 43 | plugin :tmp_restart 44 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | get 'welcome/index' 3 | root 'welcome#index' 4 | mount API => '/' 5 | end 6 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) 7 | # Character.create(name: "Luke", movie: movies.first) 8 | -------------------------------------------------------------------------------- /gemfiles/rails_6.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source 'https://rubygems.org' 4 | 5 | gem 'bootsnap', require: false 6 | gem 'concurrent-ruby', '1.3.4' 7 | gem 'grape', '~> 2.1' 8 | gem 'grape-swagger' 9 | gem 'importmap-rails' 10 | gem 'jbuilder' 11 | gem 'pg', '~> 1.1' 12 | gem 'puma' 13 | gem 'rails', '~> 6.0' 14 | gem 'sprockets-rails' 15 | gem 'stimulus-rails' 16 | gem 'turbo-rails' 17 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] 18 | 19 | group :development, :test do 20 | gem 'debug', platforms: %i[mri mingw x64_mingw] 21 | end 22 | 23 | group :development do 24 | gem 'appraisal' 25 | gem 'web-console' 26 | end 27 | 28 | group :test do 29 | gem 'capybara' 30 | gem 'rspec' 31 | gem 'rspec-rails' 32 | gem 'rubocop', '1.62.1' 33 | gem 'rubocop-capybara' 34 | gem 'rubocop-rails' 35 | gem 'rubocop-rake' 36 | gem 'rubocop-rspec' 37 | gem 'rubocop-rspec_rails' 38 | gem 'selenium-webdriver', '4.20' 39 | end 40 | -------------------------------------------------------------------------------- /gemfiles/rails_6_1.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source 'https://rubygems.org' 4 | 5 | gem 'bootsnap', require: false 6 | gem 'concurrent-ruby', '1.3.4' 7 | gem 'grape', '~> 2.1' 8 | gem 'grape-swagger' 9 | gem 'importmap-rails' 10 | gem 'jbuilder' 11 | gem 'pg', '~> 1.1' 12 | gem 'puma' 13 | gem 'rails', '~> 6.1' 14 | gem 'sprockets-rails' 15 | gem 'stimulus-rails' 16 | gem 'turbo-rails' 17 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] 18 | 19 | group :development, :test do 20 | gem 'debug', platforms: %i[mri mingw x64_mingw] 21 | end 22 | 23 | group :development do 24 | gem 'appraisal' 25 | gem 'web-console' 26 | end 27 | 28 | group :test do 29 | gem 'capybara' 30 | gem 'rspec' 31 | gem 'rspec-rails' 32 | gem 'rubocop', '1.62.1' 33 | gem 'rubocop-capybara' 34 | gem 'rubocop-rails' 35 | gem 'rubocop-rake' 36 | gem 'rubocop-rspec' 37 | gem 'rubocop-rspec_rails' 38 | gem 'selenium-webdriver', '4.20' 39 | end 40 | -------------------------------------------------------------------------------- /gemfiles/rails_7.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source 'https://rubygems.org' 4 | 5 | gem 'bootsnap', require: false 6 | gem 'concurrent-ruby', '1.3.4' 7 | gem 'grape', '~> 2.1' 8 | gem 'grape-swagger' 9 | gem 'importmap-rails' 10 | gem 'jbuilder' 11 | gem 'pg', '~> 1.1' 12 | gem 'puma' 13 | gem 'rails', '~> 7.0' 14 | gem 'sprockets-rails' 15 | gem 'stimulus-rails' 16 | gem 'turbo-rails' 17 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] 18 | 19 | group :development, :test do 20 | gem 'debug', platforms: %i[mri mingw x64_mingw] 21 | end 22 | 23 | group :development do 24 | gem 'appraisal' 25 | gem 'web-console' 26 | end 27 | 28 | group :test do 29 | gem 'capybara' 30 | gem 'rspec' 31 | gem 'rspec-rails' 32 | gem 'rubocop', '1.62.1' 33 | gem 'rubocop-capybara' 34 | gem 'rubocop-rails' 35 | gem 'rubocop-rake' 36 | gem 'rubocop-rspec' 37 | gem 'rubocop-rspec_rails' 38 | gem 'selenium-webdriver', '4.20' 39 | end 40 | -------------------------------------------------------------------------------- /gemfiles/rails_edge.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source 'https://rubygems.org' 4 | 5 | gem 'bootsnap', require: false 6 | gem 'concurrent-ruby', '1.3.4' 7 | gem 'grape', '~> 2.1' 8 | gem 'grape-swagger' 9 | gem 'importmap-rails' 10 | gem 'jbuilder' 11 | gem 'pg', '~> 1.1' 12 | gem 'puma' 13 | gem 'rails', git: 'https://github.com/rails/rails.git' 14 | gem 'sprockets-rails' 15 | gem 'stimulus-rails' 16 | gem 'turbo-rails' 17 | gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] 18 | 19 | group :development, :test do 20 | gem 'debug', platforms: %i[mri mingw x64_mingw] 21 | end 22 | 23 | group :development do 24 | gem 'appraisal' 25 | gem 'web-console' 26 | end 27 | 28 | group :test do 29 | gem 'capybara' 30 | gem 'rspec' 31 | gem 'rspec-rails' 32 | gem 'rubocop', '1.62.1' 33 | gem 'rubocop-capybara' 34 | gem 'rubocop-rails' 35 | gem 'rubocop-rake' 36 | gem 'rubocop-rspec' 37 | gem 'rubocop-rspec_rails' 38 | gem 'selenium-webdriver', '4.20' 39 | end 40 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/lib/tasks/.keep -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/log/.keep -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /public/swagger/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | SwaggerUI 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /spec/api/headers_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Acme::Headers do 4 | it 'returns all headers' do 5 | get '/api/headers' 6 | if Gem::Version.new(Rack.release) >= Gem::Version.new('3') 7 | expect(JSON.parse(response.body)).to include( 8 | 'accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 9 | 'cookie' => '', 10 | 'host' => 'www.example.com' 11 | ) 12 | else 13 | expect(JSON.parse(response.body)).to include( 14 | 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 15 | 'Cookie' => '', 16 | 'Host' => 'www.example.com' 17 | ) 18 | end 19 | end 20 | 21 | it 'returns a Host header' do 22 | get '/api/headers/Host' 23 | expect(JSON.parse(response.body)).to eq('Host' => 'www.example.com') 24 | end 25 | 26 | it 'headers are converted to pascal-case' do 27 | get '/api/headers/Host' 28 | expect(JSON.parse(response.body)).to eq('Host' => 'www.example.com') 29 | end 30 | 31 | it "headers via arg (rack #{Rack.release})" do 32 | get '/api/headers', headers: { 33 | 'HTTP_RETICULATED_SPLINE' => 42, 34 | 'Something' => 1, 35 | 'SOMETHING_ELSE' => 1 36 | } 37 | 38 | if Gem::Version.new(Rack.release) >= Gem::Version.new('3') 39 | expect(JSON.parse(response.body)).to include( 40 | 'accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 41 | 'cookie' => '', 42 | 'host' => 'www.example.com', 43 | 'reticulated-spline' => 42, 44 | 'something' => 1 45 | ) 46 | else 47 | expect(JSON.parse(response.body)).to include( 48 | 'Accept' => 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 49 | 'Cookie' => '', 50 | 'Host' => 'www.example.com', 51 | 'reticulated-spline' => 42, 52 | 'something' => 1 53 | ) 54 | end 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /spec/api/ping_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Acme::Ping do 4 | it 'ping' do 5 | get '/api/ping' 6 | expect(response.body).to eq({ ping: 'pong' }.to_json) 7 | end 8 | 9 | it 'ping with a parameter' do 10 | get '/api/ping?pong=test' 11 | expect(response.body).to eq({ ping: 'test' }.to_json) 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/api/post_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Acme::Post do 4 | [true, false].each do |reticulated| 5 | it "POST #{reticulated ? 'reticulated' : 'unreticulated'} spline" do 6 | post '/api/spline', params: { 'reticulated' => reticulated }, as: :json 7 | expect(response.status).to eq 201 8 | expect(response.body).to eq({ 'reticulated' => reticulated }.to_json) 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/api/protected_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Acme::Protected do 4 | context 'without authorization' do 5 | it 'ping' do 6 | get '/api/protected/ping' 7 | expect(response.status).to eq 401 8 | expect(response.body).to eq '' 9 | end 10 | end 11 | 12 | context 'with incorrect authorization' do 13 | it 'ping' do 14 | get '/api/protected/ping', 15 | headers: { 16 | 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials('foo', 'bar') 17 | } 18 | 19 | expect(response.status).to eq 401 20 | expect(response.body).to eq '' 21 | end 22 | end 23 | 24 | context 'with authorization' do 25 | it 'ping' do 26 | get '/api/protected/ping', 27 | headers: { 28 | 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials('username', 'password') 29 | } 30 | 31 | expect(response.status).to eq 200 32 | expect(response.body).to eq({ ping: 'pong' }.to_json) 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /spec/api/raise_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe Acme::Raise do 4 | it 'raises' do 5 | expect { get '/api/raise' }.to raise_error('Unexpected error.') 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/controllers/welcome_controller_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe WelcomeController, type: :request do 4 | describe "GET 'index'" do 5 | it 'returns http success' do 6 | get welcome_index_path 7 | expect(response).to be_successful 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/features/homepage_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Homepage', :js, type: :feature do 4 | before do 5 | visit '/' 6 | end 7 | 8 | it 'displays index.html page' do 9 | expect(page.find('h1')).to have_content 'Grape' 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/features/swagger_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'Swagger', :js, type: :feature do 4 | before do 5 | visit '/swagger' 6 | end 7 | 8 | it 'displays Swagger page' do 9 | expect(page.find('.title')).to have_content 'grape-on-rails' 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/helpers/welcome_helper_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe WelcomeHelper do 4 | end 5 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | ENV['RAILS_ENV'] = 'test' 4 | 5 | require File.expand_path('../config/environment', __dir__) 6 | 7 | require 'rspec/rails' 8 | RSpec.configure do |config| 9 | config.mock_with :rspec 10 | config.expect_with :rspec 11 | config.include RSpec::Rails::RequestExampleGroup, type: :request, file_path: %r{spec/api} 12 | end 13 | 14 | require 'capybara/rspec' 15 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/storage/.keep -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/tmp/.keep -------------------------------------------------------------------------------- /tmp/pids/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/tmp/pids/.keep -------------------------------------------------------------------------------- /tmp/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/tmp/storage/.keep -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ruby-grape/grape-on-rails/c8521c2e1e65ef3bae15b944d36c410841c6b588/vendor/.keep --------------------------------------------------------------------------------