This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
311 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,7 @@ | |
/tmp | ||
coverage | ||
.env | ||
|
||
.byebug_history | ||
|
||
*.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ Documentation: | |
AllCops: | ||
RunRailsCops: true | ||
Exclude: | ||
- db/** | ||
- config/** | ||
- db/**/* | ||
- config/**/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
language: ruby | ||
rvm: | ||
- 2.2.3 | ||
sudo: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# QuickSubmit | ||
|
||
[![Build Status](https://travis-ci.org/MITLibraries/QuickSubmit.svg)](https://travis-ci.org/MITLibraries/QuickSubmit) | ||
[![Dependency Status](https://gemnasium.com/MITLibraries/QuickSubmit.svg)](https://gemnasium.com/MITLibraries/QuickSubmit) | ||
[![Code Climate](https://codeclimate.com/github/MITLibraries/QuickSubmit/badges/gpa.svg)](https://codeclimate.com/github/MITLibraries/QuickSubmit) | ||
|
||
## What is this? | ||
|
||
QuickSubmit will be a brief form where users can upload an article along with sparse metadata. This will be transformed into METS and then SWORD and submitted to an Institutional Repository (DSpace for now). |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ | |
* | ||
*= require_tree . | ||
*= require_self | ||
*= require rails_bootstrap_forms | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
label.required:after { | ||
content:" *"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class SubmissionsController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def new | ||
@submission = Submission.new | ||
@submission.user = current_user | ||
end | ||
|
||
def create | ||
@submission = Submission.new(submission_params) | ||
@submission.user = current_user | ||
if @submission.save | ||
flash.notice = 'Your Submission is now in progress.' | ||
redirect_to root_path | ||
else | ||
render 'new' | ||
end | ||
end | ||
|
||
private | ||
|
||
def submission_params | ||
params.require(:submission).permit(:title, :agreed_to_license, :author, | ||
:journal, :doi, :grant_number, :doe) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# == Schema Information | ||
# | ||
# Table name: submissions | ||
# | ||
# id :integer not null, primary key | ||
# user_id :integer | ||
# title :string not null | ||
# journal :string | ||
# doi :string | ||
# author :string | ||
# doe :boolean | ||
# grant_number :string | ||
# agreed_to_license :boolean | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
class Submission < ActiveRecord::Base | ||
belongs_to :user | ||
validates :user, presence: true | ||
validates :title, presence: true | ||
validates :agreed_to_license, inclusion: { in: [true] } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<h1>MIT DSpace Quick Submit</h1> | ||
|
||
<%= bootstrap_form_for(@submission, layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10") do |f| %> | ||
<%= f.alert_message "Please fix the errors below." %> | ||
<%= f.text_field :author %> | ||
<%= f.text_field :title %> | ||
<%= f.text_field :journal %> | ||
<%= f.text_field :doi %> | ||
<%= f.text_field :grant_number %> | ||
<%= f.form_group :doe do %> | ||
<%= f.check_box :doe, label: "This submission was funded in part by grants from the DOE." %> | ||
<% end %> | ||
<%= f.form_group :agreed_to_license do %> | ||
<%= f.check_box :agreed_to_license, | ||
label: "I am authorized to submit this article." %> | ||
<% end %> | ||
<%= f.form_group do %> | ||
<%= f.submit %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class CreateSubmissions < ActiveRecord::Migration | ||
def change | ||
create_table :submissions do |t| | ||
t.belongs_to :user, index: true | ||
|
||
t.string :title, null: false | ||
t.string :journal | ||
t.string :doi | ||
t.string :author | ||
t.boolean :doe | ||
t.string :grant_number | ||
t.boolean :agreed_to_license | ||
|
||
t.timestamps null: false | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'test_helper' | ||
|
||
class SubmissionsControllerTest < ActionController::TestCase | ||
test 'non signed in user should redirect to login requesting new' do | ||
get :new | ||
assert_response :redirect | ||
end | ||
|
||
test 'signed in user should get new' do | ||
sign_in users(:one) | ||
get :new | ||
assert_response :success | ||
end | ||
|
||
test 'non signed in user should redirect to login posting to create' do | ||
post :create | ||
assert_response :redirect | ||
end | ||
|
||
test 'signed in user can post to create' do | ||
sign_in users(:one) | ||
post :create, submission: { 'title': '' } | ||
assert_response :success | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'test_helper' | ||
|
||
class SubmissionPagesTest < Capybara::Rails::TestCase | ||
def setup | ||
Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] | ||
Rails.application.env_config['omniauth.auth'] = | ||
OmniAuth.config.mock_auth[:mit_oauth2] | ||
OmniAuth.config.test_mode = true | ||
end | ||
|
||
def teardown | ||
OmniAuth.config.test_mode = false | ||
OmniAuth.config.mock_auth[:mit_oauth2] = nil | ||
end | ||
|
||
def mock_auth | ||
OmniAuth.config.mock_auth[:mit_oauth2] = | ||
OmniAuth::AuthHash.new(provider: 'mit_oauth2', | ||
uid: '123545', | ||
info: { email: 'bob@asdf.com' }) | ||
visit '/users/auth/mit_oauth2/callback' | ||
end | ||
|
||
test 'requires signed_in user' do | ||
visit new_submission_path | ||
assert_equal(root_path, current_path) | ||
assert_text('Sign in') | ||
assert_text('You need to sign in or sign up before continuing.') | ||
end | ||
|
||
test 'authenticated users can view the form' do | ||
mock_auth | ||
visit new_submission_path | ||
assert_equal(new_submission_path, current_path) | ||
end | ||
|
||
test 'invalid form retains valid portions' do | ||
mock_auth | ||
visit new_submission_path | ||
fill_in('Journal', with: 'Super Mega Journal') | ||
click_on('Create Submission') | ||
assert_text('Please fix the errors below') | ||
assert_text("Title can't be blank") | ||
assert_text('Agreed to license is not included in the list') | ||
assert_selector("input[value='Super Mega Journal']") | ||
end | ||
|
||
test 'invalid form submit does not create new submissions' do | ||
mock_auth | ||
subs = Submission.count | ||
visit new_submission_path | ||
fill_in('Journal', with: 'Super Mega Journal') | ||
click_on('Create Submission') | ||
assert_equal(Submission.count, subs) | ||
end | ||
|
||
test 'valid form creates new submission' do | ||
mock_auth | ||
subs = Submission.count | ||
visit new_submission_path | ||
fill_in('Journal', with: 'Super Mega Journal') | ||
fill_in('Title', with: 'Alphabetical Order is Good Enough') | ||
check('I am authorized to submit this article.') | ||
click_on('Create Submission') | ||
assert_equal(Submission.count, (subs + 1)) | ||
assert_equal('bob@asdf.com', Submission.last.user.email) | ||
assert_equal(root_path, current_path) | ||
assert_text('Your Submission is now in progress') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# == Schema Information | ||
# | ||
# Table name: submissions | ||
# | ||
# id :integer not null, primary key | ||
# user_id :integer | ||
# title :string not null | ||
# journal :string | ||
# doi :string | ||
# author :string | ||
# doe :boolean | ||
# grant_number :string | ||
# agreed_to_license :boolean | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
|
||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
sub_one: | ||
title: 'Popcorn is a fruit.' | ||
agreed_to_license: true | ||
user: one | ||
|
||
sub_two: | ||
title: 'Simple Secret Substitution Songs' | ||
user: two | ||
journal: 'Journal of Popcorn Management' | ||
doi: 'doi:10.10.1038/nphys1170' | ||
author: 'Lastname, Firstname' | ||
doe: true | ||
grant_number: 'asdf123' | ||
agreed_to_license: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.