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

Mock orcid login in dev environment #1375

Open
wants to merge 1 commit into
base: main
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
21 changes: 21 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.

config.log_level = :debug

# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
Expand Down Expand Up @@ -78,4 +80,23 @@

# Raise error when a before_action's only/except options reference missing actions.
config.action_controller.raise_on_missing_callback_actions = true

# Mock the OmniAuth provider for orcid in dev environment
# Rather than actually pinging orcid, auto-login as a
# test user that is an editor and admin (see db/seed.rb)
# the uid and provider need to match in order for
# a new account to not be created (and use the one in db/seed.rb)
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:orcid] = OmniAuth::AuthHash.new({
:provider => 'orcid',
:uid => '12345',
:info => {
:name => 'Lord Fakington',
:email => '[email protected]'
},
:credentials => {
:token => '56789',
:expires_at => 10.years.since
}
})
end
40 changes: 33 additions & 7 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,21 +357,34 @@

case Rails.env
when "development"
aeic = Editor.create!(
aeic = Editor.find_or_initialize_by(login: "aeicfake")
aeic.update(
kind: "board",
first_name: "Editor In Chief",
last_name: "Fakington",
login: "aeicfake",
email: "[email protected]",
categories: ["Astronomy"]
)
track = Track.create!(
code: 0,
aeic.save

track = Track.find_or_initialize_by(code: 0)
track.update(
name: "Railroad",
short_name: "rail",
aeics: [aeic]
)
editor = Editor.create!(
track.save

subject = Subject.find_or_initialize_by(name: "Trains")
subject.update(
track: track,
created_at: 10.minutes.ago,
updated_at: Time.now
)
subject.save

editor = Editor.find_or_initialize_by(login: 'lordfake')
editor.update(
kind: "topic",
first_name: "Lord",
last_name: "Fakington",
Expand All @@ -380,13 +393,26 @@
categories: ["Astronomy"],
tracks: [track]
)
user = User.create!(
editor.save

editor_user = User.find_or_initialize_by(uid: 12345)
editor_user.update(
name: 'Lord Fakington',
email: '[email protected]',
admin: true,
provider: 'orcid',
github_username: 'lordfake_namedoesnt_exist',
editor: editor
)
editor_user.save

user = User.create(
name: "Sneakers T. Rat",
email: "[email protected]",
github_username: "fakeuser_namedoesnt_exist"
)

paper = Paper.create!(
paper = Paper.create(
editor: editor,
submitting_author: user,
title: "On the mysteries of draperies and various such textiles",
Expand Down