Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTI-120: Fixed replaced ENV to Rails Environmental Variable configura… #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ gem 'coffee-rails', '~> 5.0', '>= 5.0.0'
gem 'http'

gem 'addressable', '~> 2.7'
gem 'bundler', '>=2.1.4'
gem 'faraday'
gem 'oauthenticator', '~> 1.3'

gem 'bundler', '>=2.1.4'
gem 'psych', '< 4'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
Expand Down
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ GEM
railties (>= 3.2)
erubi (1.11.0)
execjs (2.8.1)
faraday (1.10.1)
faraday (1.10.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand Down Expand Up @@ -220,14 +220,12 @@ GEM
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.16.2)
minitest-stub_any_instance (1.0.3)
multi_json (1.15.0)
multipart-post (2.2.3)
nio4r (2.5.8)
nokogiri (1.13.8)
mini_portile2 (~> 2.8.0)
nokogiri (1.13.7-x86_64-linux)
racc (~> 1.4)
oauth (0.5.10)
oauthenticator (1.4.0)
Expand All @@ -236,10 +234,11 @@ GEM
json
rack (>= 1.4, < 3.0)
parallel (1.22.1)
parser (3.1.2.1)
parser (3.1.2.0)
ast (~> 2.4.1)
pg (1.4.3)
pg (1.4.1)
popper_js (1.16.0)
psych (3.3.2)
public_suffix (4.0.7)
puma (5.6.4)
nio4r (~> 2.0)
Expand Down Expand Up @@ -363,7 +362,7 @@ GEM
execjs (>= 0.3.0, < 3)
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.11)
tilt (2.0.10)
tins (1.31.1)
sync
turbolinks (5.2.1)
Expand Down Expand Up @@ -392,7 +391,7 @@ GEM
zeitwerk (2.6.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
activerecord-session_store
Expand All @@ -418,6 +417,7 @@ DEPENDENCIES
oauth (~> 0.5.1)
oauthenticator (~> 1.3)
pg (>= 0.4.4)
psych (< 4)
puma (>= 4.3.5)
rails (~> 6.0, >= 6.0.5.1)
rails_lti2_provider!
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/registration_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RegistrationController < ApplicationController
include TemporaryStore

def list
if ENV['DEVELOPER_MODE_ENABLED'] != 'true'
if Rails.configuration.developer_mode_enabled != 'true'
render(file: Rails.root.join('public/404'), layout: false, status: :not_found)
return
end
Expand All @@ -40,7 +40,7 @@ def list
# production - use rails task
def new
@app = ENV['DEFAULT_LTI_TOOL']
@app ||= 'default' if ENV['DEVELOPER_MODE_ENABLED'] == 'true'
@app ||= 'default' if Rails.configuration.developer_mode_enabled == 'true'
@apps = lti_apps
set_temp_keys
set_starter_info
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/tool_profile_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ToolProfileController < ApplicationController

# show xml builder for customization in tool consumer url
def xml_builder
if ENV['DEVELOPER_MODE_ENABLED'] != 'true' && params[:app] == 'default'
if Rails.configuration.developer_mode_enabled != 'true' && params[:app] == 'default'
render(file: Rails.root.join('public/404'), layout: false, status: :not_found)
return
end
Expand Down Expand Up @@ -82,7 +82,7 @@ def json_config
end

def xml_config
if ENV['DEVELOPER_MODE_ENABLED'] != 'true' && params[:app] == 'default'
if Rails.configuration.developer_mode_enabled != 'true' && params[:app] == 'default'
render(file: Rails.root.join('public/404'), layout: false, status: :not_found)
return
end
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
use_doorkeeper do
# Including 'skip_controllers :application' disables the controller for managing external applications
# [http://example.com/lti/oauth/applications]
skip_controllers :applications unless ENV['DEVELOPER_MODE_ENABLED'] == 'true'
skip_controllers :applications unless Rails.configuration.developer_mode_enabled == 'true'
end

get '/', to: 'application#index', as: 'lti_home'
Expand Down
18 changes: 9 additions & 9 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true
end

create_table "rails_lti2_provider_lti_launches", id: :serial, force: :cascade do |t|
create_table "rails_lti2_provider_lti_launches", force: :cascade do |t|
t.bigint "tool_id"
t.string "nonce"
t.text "message"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end

create_table "rails_lti2_provider_registrations", id: :serial, force: :cascade do |t|
create_table "rails_lti2_provider_registrations", force: :cascade do |t|
t.string "uuid"
t.text "registration_request_params"
t.text "tool_proxy_json"
t.string "workflow_state"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.bigint "tool_id"
t.text "correlation_id"
t.index ["correlation_id"], name: "index_rails_lti2_provider_registrations_on_correlation_id", unique: true
Expand All @@ -84,12 +84,12 @@
t.index ["uid"], name: "index_tenant_uid", unique: true
end

create_table "rails_lti2_provider_tools", id: :serial, force: :cascade do |t|
create_table "rails_lti2_provider_tools", force: :cascade do |t|
t.string "uuid"
t.text "shared_secret"
t.text "tool_settings"
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "lti_version"
t.integer "tenant_id"
t.datetime "expired_at"
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/tool_profile_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
RSpec.describe(ToolProfileController, type: :controller) do
describe 'GET :app/xml_config' do
it 'gives an xml page when developer mode enabled' do
ENV['DEVELOPER_MODE_ENABLED'] = 'true'
Rails.configuration.developer_mode_enabled = 'true'
get :xml_config, params: { app: 'default' }
expect(response).to(be_successful)

Expand Down
2 changes: 1 addition & 1 deletion test/controllers/tool_profile_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class ToolProfileControllerTest < ActionDispatch::IntegrationTest
test 'responds with xml_config for default with no parameters when developer mode is true' do
ENV['DEVELOPER_MODE_ENABLED'] = 'true'
Rails.configuration.developer_mode_enabled = 'true'
get xml_config_path('default')

# Response must be successful
Expand Down