transferred Code Ocean from original repository to GitHub

This commit is contained in:
Hauke Klement
2015-01-22 09:51:49 +01:00
commit 4cbf9970b1
683 changed files with 11979 additions and 0 deletions

View File

@ -0,0 +1,54 @@
require 'rails_helper'
describe 'Authentication' do
let(:user) { FactoryGirl.create(:admin) }
let(:password) { FactoryGirl.attributes_for(:admin)[:password] }
context 'when signed out' do
before(:each) { visit(root_path) }
it 'displays a sign in link' do
expect(page).to have_content(I18n.t('sessions.new.link'))
end
context 'with valid credentials' do
it 'allows to sign in' do
click_link(I18n.t('sessions.new.link'))
fill_in('Email', with: user.email)
fill_in('Password', with: password)
click_button(I18n.t('sessions.new.link'))
expect(page).to have_content(I18n.t('sessions.create.success'))
end
end
context 'with invalid credentials' do
it 'does not allow to sign in' do
click_link(I18n.t('sessions.new.link'))
fill_in('Email', with: user.email)
fill_in('Password', with: password.reverse)
click_button(I18n.t('sessions.new.link'))
expect(page).to have_content(I18n.t('sessions.create.failure'))
end
end
end
context 'when signed in' do
before(:each) do
sign_in(user, password)
visit(root_path)
end
it "displays the user's name" do
expect(page).to have_content(user.name)
end
it 'displays a sign out link' do
expect(page).to have_content(I18n.t('sessions.destroy.link'))
end
it 'allows to sign out' do
click_link(I18n.t('sessions.destroy.link'))
expect(page).to have_content(I18n.t('sessions.destroy.success'))
end
end
end

View File

@ -0,0 +1,34 @@
require 'rails_helper'
describe 'Authorization' do
context 'as an admin' do
let(:user) { FactoryGirl.create(:admin) }
before(:each) { allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) }
%w[consumer execution_environment exercise file_type internal_user].each do |model|
expect_permitted_path(:"new_#{model}_path")
end
end
context 'as an external user' do
let(:user) { FactoryGirl.create(:external_user) }
before(:each) { allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) }
%w[consumer execution_environment exercise file_type internal_user].each do |model|
expect_forbidden_path(:"new_#{model}_path")
end
end
context 'as a teacher' do
let(:user) { FactoryGirl.create(:teacher) }
before(:each) { allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) }
%w[consumer internal_user].each do |model|
expect_forbidden_path(:"new_#{model}_path")
end
%w[execution_environment exercise file_type].each do |model|
expect_permitted_path(:"new_#{model}_path")
end
end
end

View File

@ -0,0 +1,7 @@
require 'rails_helper'
describe 'Factories' do
it 'are all valid', permitted_execution_time: 30 do
expect { FactoryGirl.lint }.not_to raise_error
end
end