-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes in auth spec description and courses tests
- Loading branch information
1 parent
5ac63c8
commit a490d8e
Showing
2 changed files
with
24 additions
and
66 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
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 |
---|---|---|
@@ -1,6 +1,28 @@ | ||
require 'swagger_helper' | ||
require 'json_web_token' | ||
|
||
RSpec.describe 'api/v1/courses', type: :request do | ||
before(:all) do | ||
# Create roles in hierarchy | ||
@super_admin = Role.find_or_create_by(name: 'Super Administrator') | ||
@admin = Role.find_or_create_by(name: 'Administrator', parent_id: @super_admin.id) | ||
@instructor = Role.find_or_create_by(name: 'Instructor', parent_id: @admin.id) | ||
@ta = Role.find_or_create_by(name: 'Teaching Assistant', parent_id: @instructor.id) | ||
@student = Role.find_or_create_by(name: 'Student', parent_id: @ta.id) | ||
end | ||
|
||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: @instructor.id, | ||
full_name: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
|
||
let(:token) { JsonWebToken.encode({id: prof.id}) } | ||
let(:Authorization) { "Bearer #{token}" } | ||
|
||
|
||
# GET /courses/{id}/add_ta/{ta_id} | ||
path '/api/v1/courses/{id}/add_ta/{ta_id}' do | ||
|
@@ -60,14 +82,6 @@ | |
path '/api/v1/courses/{id}/tas' do | ||
parameter name: 'id', in: :path, type: :string, description: 'id' | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { Course.create(institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank') } | ||
let(:id) { course.id } | ||
get('view_tas course') do | ||
|
@@ -90,14 +104,6 @@ | |
parameter name: 'id', in: :path, type: :string, description: 'id' | ||
parameter name: 'ta_id', in: :path, type: :string, description: 'ta_id' | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { Course.create(institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank') } | ||
let(:id) { course.id } | ||
let(:ta) { User.create( | ||
|
@@ -134,14 +140,6 @@ | |
path '/api/v1/courses/{id}/copy' do | ||
parameter name: 'id', in: :path, type: :string, description: 'id' | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { Course.create(institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank') } | ||
let(:id) { course.id } | ||
get('copy course') do | ||
|
@@ -192,14 +190,6 @@ | |
} | ||
response(201, 'successful') do | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { { institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank' } } | ||
after do |example| | ||
example.metadata[:response][:content] = { | ||
|
@@ -217,14 +207,6 @@ | |
path '/api/v1/courses/{id}' do | ||
parameter name: 'id', in: :path, type: :string, description: 'id' | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { Course.create(institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank') } | ||
let(:id) { course.id } | ||
get('show course') do | ||
|
@@ -257,14 +239,6 @@ | |
required: %w[] | ||
} | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { Course.create(institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank') } | ||
let(:id) { course.id } | ||
response(200, 'successful') do | ||
|
@@ -295,14 +269,6 @@ | |
required: %w[] | ||
} | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { Course.create(institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank') } | ||
let(:id) { course.id } | ||
response(200, 'successful') do | ||
|
@@ -321,14 +287,6 @@ | |
delete('delete course') do | ||
tags 'Courses' | ||
let(:institution) { Institution.create(name: "NC State") } | ||
let(:prof) { User.create( | ||
name: "profa", | ||
password_digest: "password", | ||
role_id: 4, | ||
fullname: "Prof A", | ||
email: "[email protected]", | ||
mru_directory_path: "/home/testuser", | ||
) } | ||
let(:course) { Course.create(institution_id: institution.id, instructor_id: prof.id, directory_path: 'samplepath', name: 'OODD', info: 'blank') } | ||
let(:id) { course.id } | ||
response(204, 'successful') do | ||
|