openstax_api 8.3.1 → 8.3.2

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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/lib/openstax/api/version.rb +1 -1
  3. metadata +2 -120
  4. data/spec/controllers/openstax/api/v1/api_controller_spec.rb +0 -176
  5. data/spec/dummy/README.md +0 -1
  6. data/spec/dummy/Rakefile +0 -6
  7. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  8. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  9. data/spec/dummy/app/controllers/api/v1/dummy_controller.rb +0 -23
  10. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  11. data/spec/dummy/app/models/user.rb +0 -2
  12. data/spec/dummy/app/representers/user_representer.rb +0 -13
  13. data/spec/dummy/app/representers/user_search_representer.rb +0 -5
  14. data/spec/dummy/app/routines/search_users.rb +0 -42
  15. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  16. data/spec/dummy/bin/bundle +0 -3
  17. data/spec/dummy/bin/rails +0 -4
  18. data/spec/dummy/bin/rake +0 -4
  19. data/spec/dummy/config.ru +0 -4
  20. data/spec/dummy/config/application.rb +0 -23
  21. data/spec/dummy/config/boot.rb +0 -5
  22. data/spec/dummy/config/database.yml +0 -25
  23. data/spec/dummy/config/environment.rb +0 -7
  24. data/spec/dummy/config/environments/development.rb +0 -37
  25. data/spec/dummy/config/environments/production.rb +0 -78
  26. data/spec/dummy/config/environments/test.rb +0 -39
  27. data/spec/dummy/config/initializers/assets.rb +0 -8
  28. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  29. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  30. data/spec/dummy/config/initializers/doorkeeper.rb +0 -75
  31. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  32. data/spec/dummy/config/initializers/inflections.rb +0 -16
  33. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  34. data/spec/dummy/config/initializers/openstax_api.rb +0 -4
  35. data/spec/dummy/config/initializers/session_store.rb +0 -3
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  37. data/spec/dummy/config/locales/en.yml +0 -23
  38. data/spec/dummy/config/routes.rb +0 -6
  39. data/spec/dummy/config/secrets.yml +0 -22
  40. data/spec/dummy/db/development.sqlite3 +0 -0
  41. data/spec/dummy/db/migrate/0_create_doorkeeper_tables.rb +0 -42
  42. data/spec/dummy/db/migrate/1_create_users.rb +0 -16
  43. data/spec/dummy/db/schema.rb +0 -68
  44. data/spec/dummy/db/test.sqlite3 +0 -0
  45. data/spec/dummy/lib/controller_includes.rb +0 -3
  46. data/spec/dummy/public/404.html +0 -67
  47. data/spec/dummy/public/422.html +0 -67
  48. data/spec/dummy/public/500.html +0 -66
  49. data/spec/dummy/public/favicon.ico +0 -0
  50. data/spec/factories/user.rb +0 -8
  51. data/spec/lib/openstax/api/apipie_spec.rb +0 -15
  52. data/spec/lib/openstax/api/constraints_spec.rb +0 -84
  53. data/spec/lib/openstax/api/doorkeeper_application_includes_spec.rb +0 -17
  54. data/spec/lib/openstax/api/params_spec.rb +0 -78
  55. data/spec/lib/openstax/api/representable_schema_printer_spec.rb +0 -27
  56. data/spec/lib/openstax/api/roar_spec.rb +0 -45
  57. data/spec/lib/openstax/api/routing_mapper_includes_spec.rb +0 -20
  58. data/spec/lib/openstax_api_spec.rb +0 -19
  59. data/spec/models/openstax/api/api_user_spec.rb +0 -47
  60. data/spec/rails_helper.rb +0 -54
  61. data/spec/representers/openstax/api/v1/abstract_search_representer_spec.rb +0 -144
  62. data/spec/spec_helper.rb +0 -86
@@ -1,6 +0,0 @@
1
- Rails.application.routes.draw do
2
- api :v1, :default => true do
3
- get 'dummy', controller: 'dummy'
4
- get 'explode', controller: 'dummy'
5
- end
6
- end
@@ -1,22 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key is used for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
-
6
- # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rake secret` to generate a secure secret key.
9
-
10
- # Make sure the secrets in this file are kept private
11
- # if you're sharing your code publicly.
12
-
13
- development:
14
- secret_key_base: 4f412fca80a6e4d4e76735b29e53c0550675a32c64ed6129d8ad20e2e691483af164f708181013b1d0df0248c1c642a74cde6048589066f97aa32b92d99ff498
15
-
16
- test:
17
- secret_key_base: f892dc05486e6580aca8df7656fcffe0c073421226bc49c5fca8b8c2509ffd8817acb8cbc0eeddb1f0c1c4494623c25c4810ca19a44b701410ce492e32e6cb2b
18
-
19
- # Do not keep production secrets in the repository,
20
- # instead read values from the environment.
21
- production:
22
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
File without changes
@@ -1,42 +0,0 @@
1
- class CreateDoorkeeperTables < ActiveRecord::Migration
2
- def change
3
- create_table :oauth_applications do |t|
4
- t.string :name, :null => false
5
- t.string :uid, :null => false
6
- t.string :secret, :null => false
7
- t.text :redirect_uri, :null => false
8
- t.timestamps
9
- end
10
-
11
- add_index :oauth_applications, :uid, :unique => true
12
-
13
- create_table :oauth_access_grants do |t|
14
- t.integer :resource_owner_id, :null => false
15
- t.integer :application_id, :null => false
16
- t.string :token, :null => false
17
- t.integer :expires_in, :null => false
18
- t.text :redirect_uri, :null => false
19
- t.datetime :created_at, :null => false
20
- t.datetime :revoked_at
21
- t.string :scopes
22
- end
23
-
24
- add_index :oauth_access_grants, :token, :unique => true
25
-
26
- create_table :oauth_access_tokens do |t|
27
- t.integer :resource_owner_id
28
- t.integer :application_id
29
- t.string :token, :null => false
30
- t.string :refresh_token
31
- t.integer :expires_in
32
- t.datetime :revoked_at
33
- t.datetime :created_at, :null => false
34
- t.string :scopes
35
- end
36
-
37
- add_index :oauth_access_tokens, :token, :unique => true
38
- add_index :oauth_access_tokens, :resource_owner_id
39
- add_index :oauth_access_tokens, :refresh_token, :unique => true
40
-
41
- end
42
- end
@@ -1,16 +0,0 @@
1
- class CreateUsers < ActiveRecord::Migration
2
- def change
3
- create_table :users do |t|
4
- t.string :username, null: false
5
- t.string :password_hash, null: false
6
- t.string :name, null: false
7
- t.string :email, null: false
8
-
9
- t.timestamps
10
- end
11
-
12
- add_index :users, :username
13
- add_index :users, :name
14
- add_index :users, :email
15
- end
16
- end
@@ -1,68 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 1) do
15
-
16
- create_table "oauth_access_grants", force: true do |t|
17
- t.integer "resource_owner_id", null: false
18
- t.integer "application_id", null: false
19
- t.string "token", null: false
20
- t.integer "expires_in", null: false
21
- t.text "redirect_uri", null: false
22
- t.datetime "created_at", null: false
23
- t.datetime "revoked_at"
24
- t.string "scopes"
25
- end
26
-
27
- add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true
28
-
29
- create_table "oauth_access_tokens", force: true do |t|
30
- t.integer "resource_owner_id"
31
- t.integer "application_id"
32
- t.string "token", null: false
33
- t.string "refresh_token"
34
- t.integer "expires_in"
35
- t.datetime "revoked_at"
36
- t.datetime "created_at", null: false
37
- t.string "scopes"
38
- end
39
-
40
- add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
41
- add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
42
- add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true
43
-
44
- create_table "oauth_applications", force: true do |t|
45
- t.string "name", null: false
46
- t.string "uid", null: false
47
- t.string "secret", null: false
48
- t.text "redirect_uri", null: false
49
- t.datetime "created_at"
50
- t.datetime "updated_at"
51
- end
52
-
53
- add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true
54
-
55
- create_table "users", force: true do |t|
56
- t.string "username", null: false
57
- t.string "password_hash", null: false
58
- t.string "name", null: false
59
- t.string "email", null: false
60
- t.datetime "created_at"
61
- t.datetime "updated_at"
62
- end
63
-
64
- add_index "users", ["email"], name: "index_users_on_email"
65
- add_index "users", ["name"], name: "index_users_on_name"
66
- add_index "users", ["username"], name: "index_users_on_username"
67
-
68
- end
Binary file
@@ -1,3 +0,0 @@
1
- ActionController::Base.class_exec do
2
- attr_accessor :doorkeeper_token, :present_user
3
- end
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
@@ -1,8 +0,0 @@
1
- FactoryBot.define do
2
- factory :user do
3
- username { SecureRandom.hex.to_s }
4
- password_hash { SecureRandom.hex.to_s }
5
- name { Faker::Name.name }
6
- email { Faker::Internet.email }
7
- end
8
- end
@@ -1,15 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module OpenStax
4
- module Api
5
- module V1
6
- describe Apipie do
7
- it 'adds methods to ApiController class' do
8
- expect(OpenStax::Api::V1::ApiController).to respond_to(:api_example)
9
- expect(OpenStax::Api::V1::ApiController).to respond_to(:json_schema)
10
- expect(OpenStax::Api::V1::ApiController).to respond_to(:representer)
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,84 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module OpenStax
4
- module Api
5
- describe Constraints do
6
- context 'default is not defined' do
7
- let!(:constraints) { Constraints.new(version: :v1) }
8
- let(:req) { double('Request') }
9
-
10
- it 'matches if version is correct in the accept headers' do
11
- allow(req).to receive(:headers).and_return({
12
- 'Accept' => 'application/vnd.openstax.v1'
13
- })
14
- expect(constraints.matches? req).to eq true
15
- end
16
-
17
- it 'does not match if version is incorrect in the accept headers' do
18
- allow(req).to receive(:headers).and_return({
19
- 'Accept' => 'application/vnd.openstax.v2'
20
- })
21
- expect(constraints.matches? req).to eq false
22
- end
23
-
24
- it 'does not match if version is not defined in the accept headers' do
25
- allow(req).to receive(:headers).and_return({
26
- 'Accept' => '*/*',
27
- })
28
- expect(constraints.matches? req).to eq false
29
- end
30
-
31
- it 'does not match if accept is not in headers' do
32
- allow(req).to receive(:headers).and_return({
33
- 'Host' => 'localhost'
34
- })
35
- expect(constraints.matches? req).to eq false
36
- end
37
- end
38
-
39
- context 'default is defined' do
40
- let!(:constraints) { Constraints.new(version: :v1) }
41
- let!(:constraints_2) { Constraints.new(version: :v2, default: true) }
42
- let(:req) { double('Request') }
43
-
44
- it 'matches if version is correct in the accept headers or if default' do
45
- allow(req).to receive(:headers).and_return({
46
- 'Accept' => 'application/vnd.openstax.v1'
47
- })
48
- expect(constraints.matches? req).to eq true
49
- expect(constraints_2.matches? req).to eq true
50
-
51
- allow(req).to receive(:headers).and_return({
52
- 'Accept' => 'application/vnd.openstax.v2'
53
- })
54
- expect(constraints.matches? req).to eq false
55
- expect(constraints_2.matches? req).to eq true
56
- end
57
-
58
- it 'matches if version is invalid' do
59
- allow(req).to receive(:headers).and_return({
60
- 'Accept' => 'application/vnd.openstax.v3'
61
- })
62
- expect(constraints.matches? req).to eq false
63
- expect(constraints_2.matches? req).to eq true
64
- end
65
-
66
- it 'matches if version is not defined in the accept headers' do
67
- allow(req).to receive(:headers).and_return({
68
- 'Accept' => '*/*',
69
- })
70
- expect(constraints.matches? req).to eq false
71
- expect(constraints_2.matches? req).to eq true
72
- end
73
-
74
- it 'matches if accept is not in headers' do
75
- allow(req).to receive(:headers).and_return({
76
- 'Host' => 'localhost'
77
- })
78
- expect(constraints.matches? req).to eq false
79
- expect(constraints_2.matches? req).to eq true
80
- end
81
- end
82
- end
83
- end
84
- end