forked from expertiza/reimplementation-back-end
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed institutions_spec and questions
- Loading branch information
1 parent
53a04d8
commit b38870e
Showing
5 changed files
with
75 additions
and
13 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
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,7 +1,26 @@ | ||
require 'swagger_helper' | ||
|
||
require 'json_web_token' | ||
RSpec.describe 'Institutions API', 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}" } | ||
path '/api/v1/institutions' do | ||
get('list institutions') do | ||
tags 'Institutions' | ||
|
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,16 +1,53 @@ | ||
require 'swagger_helper' | ||
|
||
require 'json_web_token' | ||
# Rspec tests for questions controller | ||
def setup_instructor | ||
role = Role.find_or_create_by(name: 'Instructor', parent_id: nil) | ||
expect(role).to be_present | ||
|
||
instructor = Instructor.create!( | ||
name: 'testinstructor', | ||
email: '[email protected]', | ||
full_name: 'Test Instructor', | ||
password: '123456', | ||
role: role | ||
) | ||
expect(instructor).to be_valid | ||
|
||
instructor | ||
end | ||
RSpec.describe 'api/v1/questions', 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(:instructor) { setup_instructor } | ||
|
||
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}" } | ||
path '/api/v1/questions' do | ||
# Creation of dummy objects for the test with the help of let statements | ||
let(:role) { Role.create(name: 'Instructor', parent_id: nil, default_page_id: nil) } | ||
let(:instructor) do | ||
role | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', fullname: 'Test Instructor', password: '123456', role: role) | ||
end | ||
#let(:role) { Role.create(name: 'Instructor', parent_id: nil, default_page_id: nil) } | ||
|
||
#let(:instructor) do | ||
# role | ||
# Instructor.create(name: 'testinstructor', email: '[email protected]', full_name: 'Test Instructor', password: '123456', role: role) | ||
#end | ||
|
||
let(:questionnaire) do | ||
instructor | ||
|
@@ -147,7 +184,7 @@ | |
|
||
let(:instructor) do | ||
role | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', fullname: 'Test Instructor', password: '123456', role: role) | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', full_name: 'Test Instructor', password: '123456', role: role) | ||
end | ||
|
||
let(:questionnaire) do | ||
|
@@ -355,7 +392,7 @@ | |
|
||
let(:instructor) do | ||
role | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', fullname: 'Test Instructor', password: '123456', role: role) | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', full_name: 'Test Instructor', password: '123456', role: role) | ||
end | ||
|
||
let(:questionnaire) do | ||
|
@@ -431,7 +468,7 @@ | |
|
||
let(:instructor) do | ||
role | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', fullname: 'Test Instructor', password: '123456', role: role) | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', full_name: 'Test Instructor', password: '123456', role: role) | ||
end | ||
|
||
let(:questionnaire) do | ||
|
@@ -533,7 +570,7 @@ | |
|
||
let(:instructor) do | ||
role | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', fullname: 'Test Instructor', password: '123456', role: role) | ||
Instructor.create(name: 'testinstructor', email: '[email protected]', full_name: 'Test Instructor', password: '123456', role: role) | ||
end | ||
|
||
let(:questionnaire) do | ||
|