Move non-empty files from test dir to spec and adopt specs
Signed-off-by: Sebastian Serth <Sebastian.Serth@student.hpi.de>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe ErrorTemplateAttributesController do
|
||||
let!(:error_template_attribute) { FactoryBot.create(:error_template_attribute) }
|
||||
let(:user) { FactoryBot.create(:admin) }
|
||||
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
|
||||
|
||||
it "should get index" do
|
||||
get :index
|
||||
expect(response.status).to eq(200)
|
||||
expect(assigns(:error_template_attributes)).not_to be_nil
|
||||
end
|
||||
|
||||
it "should get new" do
|
||||
get :new
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should create error_template_attribute" do
|
||||
expect { post :create, error_template_attribute: { } }.to change(ErrorTemplateAttribute, :count).by(1)
|
||||
expect(response).to redirect_to(error_template_attribute_path(assigns(:error_template_attribute)))
|
||||
end
|
||||
|
||||
it "should show error_template_attribute" do
|
||||
get :show, id: error_template_attribute
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should get edit" do
|
||||
get :edit, id: error_template_attribute
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should update error_template_attribute" do
|
||||
patch :update, id: error_template_attribute, error_template_attribute: { }
|
||||
expect(response).to redirect_to(error_template_attribute_path(assigns(:error_template_attribute)))
|
||||
end
|
||||
|
||||
it "should destroy error_template_attribute" do
|
||||
expect { delete :destroy, id: error_template_attribute }.to change(ErrorTemplateAttribute, :count).by(-1)
|
||||
expect(response).to redirect_to(error_template_attributes_path)
|
||||
end
|
||||
end
|
43
spec/controllers/error_templates_controller_spec.rb
Normal file
43
spec/controllers/error_templates_controller_spec.rb
Normal file
@@ -0,0 +1,43 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe ErrorTemplatesController do
|
||||
let!(:error_template) { FactoryBot.create(:error_template) }
|
||||
let(:user) { FactoryBot.create(:admin) }
|
||||
before(:each) { allow(controller).to receive(:current_user).and_return(user) }
|
||||
|
||||
it "should get index" do
|
||||
get :index
|
||||
expect(response.status).to eq(200)
|
||||
expect(assigns(:error_templates)).not_to be_nil
|
||||
end
|
||||
|
||||
it "should get new" do
|
||||
get :new
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should create error_template" do
|
||||
expect { post :create, error_template: { } }.to change(ErrorTemplate, :count).by(1)
|
||||
expect(response).to redirect_to(error_template_path(assigns(:error_template)))
|
||||
end
|
||||
|
||||
it "should show error_template" do
|
||||
get :show, id: error_template
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should get edit" do
|
||||
get :edit, id: error_template
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
it "should update error_template" do
|
||||
patch :update, id: error_template, error_template: { }
|
||||
expect(response).to redirect_to(error_template_path(assigns(:error_template)))
|
||||
end
|
||||
|
||||
it "should destroy error_template" do
|
||||
expect { delete :destroy, id: error_template }.to change(ErrorTemplate, :count).by(-1)
|
||||
expect(response).to redirect_to(error_templates_path)
|
||||
end
|
||||
end
|
6
spec/factories/error_template_attributes.rb
Normal file
6
spec/factories/error_template_attributes.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory :error_template_attribute do
|
||||
key { "MyString" }
|
||||
regex { "MyString" }
|
||||
end
|
||||
end
|
7
spec/factories/error_templates.rb
Normal file
7
spec/factories/error_templates.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :error_template do
|
||||
execution_environment { nil }
|
||||
name { "MyString" }
|
||||
signature { "MyString" }
|
||||
end
|
||||
end
|
7
spec/factories/structured_error_attributes.rb
Normal file
7
spec/factories/structured_error_attributes.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryBot.define do
|
||||
factory :structured_error_attribute do
|
||||
structured_error { nil }
|
||||
error_template_attribute { nil }
|
||||
value { "MyString" }
|
||||
end
|
||||
end
|
6
spec/factories/structured_errors.rb
Normal file
6
spec/factories/structured_errors.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
FactoryBot.define do
|
||||
factory :structured_error do
|
||||
error_template { nil }
|
||||
submission { nil }
|
||||
end
|
||||
end
|
7
spec/mailers/previews/user_mailer_preview.rb
Normal file
7
spec/mailers/previews/user_mailer_preview.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class UserMailerPreview < ActionMailer::Preview
|
||||
def exercise_anomaly_detected()
|
||||
collection = ExerciseCollection.new(name: 'Hello World', user: FactoryBot.create(:admin))
|
||||
anomalies = {49 => 879.325828, 51 => 924.870057, 31 => 1031.21233, 69 => 2159.182116}
|
||||
UserMailer.exercise_anomaly_detected(collection, anomalies)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user