Update bundle (with newest rubocop version) and fix offenses
This commit is contained in:
@ -3,8 +3,8 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Authentication' do
|
||||
let(:user) { FactoryBot.create(:admin) }
|
||||
let(:password) { FactoryBot.attributes_for(:admin)[:password] }
|
||||
let(:user) { create(:admin) }
|
||||
let(:password) { attributes_for(:admin)[:password] }
|
||||
|
||||
context 'when signed out' do
|
||||
before { visit(root_path) }
|
||||
|
@ -6,7 +6,7 @@ describe 'Authorization' do
|
||||
before { allow(Runner.strategy_class).to receive(:available_images).and_return([]) }
|
||||
|
||||
context 'when being an admin' do
|
||||
let(:user) { FactoryBot.create(:admin) }
|
||||
let(:user) { create(:admin) }
|
||||
|
||||
before { allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) }
|
||||
|
||||
@ -16,7 +16,7 @@ describe 'Authorization' do
|
||||
end
|
||||
|
||||
context 'with being an external user' do
|
||||
let(:user) { FactoryBot.create(:external_user) }
|
||||
let(:user) { create(:external_user) }
|
||||
|
||||
before { allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) }
|
||||
|
||||
@ -26,7 +26,7 @@ describe 'Authorization' do
|
||||
end
|
||||
|
||||
context 'with being a teacher' do
|
||||
let(:user) { FactoryBot.create(:teacher) }
|
||||
let(:user) { create(:teacher) }
|
||||
|
||||
before { allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) }
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Editor', js: true do
|
||||
let(:exercise) { FactoryBot.create(:audio_video, description: Forgery(:lorem_ipsum).sentence) }
|
||||
let(:exercise) { create(:audio_video, description: Forgery(:lorem_ipsum).sentence) }
|
||||
let(:scoring_response) do
|
||||
[{
|
||||
status: :ok,
|
||||
@ -22,12 +22,12 @@ describe 'Editor', js: true do
|
||||
weight: 2.0,
|
||||
}]
|
||||
end
|
||||
let(:user) { FactoryBot.create(:teacher) }
|
||||
let(:user) { create(:teacher) }
|
||||
|
||||
before do
|
||||
visit(sign_in_path)
|
||||
fill_in('email', with: user.email)
|
||||
fill_in('password', with: FactoryBot.attributes_for(:teacher)[:password])
|
||||
fill_in('password', with: attributes_for(:teacher)[:password])
|
||||
click_button(I18n.t('sessions.new.link'))
|
||||
allow_any_instance_of(LtiHelper).to receive(:lti_outcome_service?).and_return(true)
|
||||
visit(implement_exercise_path(exercise))
|
||||
@ -94,7 +94,7 @@ describe 'Editor', js: true do
|
||||
end
|
||||
|
||||
it 'contains a button for submitting the exercise' do
|
||||
submission = FactoryBot.build(:submission, user: user, exercise: exercise)
|
||||
submission = build(:submission, user: user, exercise: exercise)
|
||||
allow(submission).to receive(:calculate_score).and_return(scoring_response)
|
||||
allow(Submission).to receive(:find).and_return(submission)
|
||||
click_button(I18n.t('exercises.editor.score'))
|
||||
|
@ -26,7 +26,7 @@ describe Prometheus::Controller do
|
||||
|
||||
describe 'instance count' do
|
||||
it 'initializes the metrics with the current database entries' do
|
||||
FactoryBot.create_list(:proxy_exercise, 3)
|
||||
create_list(:proxy_exercise, 3)
|
||||
described_class.register_metrics
|
||||
stub_metrics
|
||||
described_class.initialize_instance_count
|
||||
@ -35,25 +35,25 @@ describe Prometheus::Controller do
|
||||
|
||||
it 'gets notified when an object is created' do
|
||||
allow(described_class).to receive(:create_notification)
|
||||
proxy_exercise = FactoryBot.create(:proxy_exercise)
|
||||
proxy_exercise = create(:proxy_exercise)
|
||||
expect(described_class).to have_received(:create_notification).with(proxy_exercise).once
|
||||
end
|
||||
|
||||
it 'gets notified when an object is destroyed' do
|
||||
allow(described_class).to receive(:destroy_notification)
|
||||
proxy_exercise = FactoryBot.create(:proxy_exercise).destroy
|
||||
proxy_exercise = create(:proxy_exercise).destroy
|
||||
expect(described_class).to have_received(:destroy_notification).with(proxy_exercise).once
|
||||
end
|
||||
|
||||
it 'increments gauge when creating a new instance' do
|
||||
FactoryBot.create(:proxy_exercise)
|
||||
create(:proxy_exercise)
|
||||
expect(described_class.instance_variable_get(:@instance_count)).to(
|
||||
have_received(:increment).with(class: ProxyExercise.name).once
|
||||
)
|
||||
end
|
||||
|
||||
it 'decrements gauge when deleting an object' do
|
||||
FactoryBot.create(:proxy_exercise).destroy
|
||||
create(:proxy_exercise).destroy
|
||||
expect(described_class.instance_variable_get(:@instance_count)).to(
|
||||
have_received(:decrement).with(class: ProxyExercise.name).once
|
||||
)
|
||||
@ -63,7 +63,7 @@ describe Prometheus::Controller do
|
||||
describe 'rfc count' do
|
||||
context 'when initializing an rfc' do
|
||||
it 'updates rfc count when creating an ongoing rfc' do
|
||||
FactoryBot.create(:rfc)
|
||||
create(:rfc)
|
||||
expect(described_class.instance_variable_get(:@rfc_count)).to(
|
||||
have_received(:increment).with(state: RequestForComment::ONGOING).once
|
||||
)
|
||||
@ -71,7 +71,7 @@ describe Prometheus::Controller do
|
||||
end
|
||||
|
||||
context 'when changing the state of an rfc' do
|
||||
let(:rfc) { FactoryBot.create(:rfc) }
|
||||
let(:rfc) { create(:rfc) }
|
||||
|
||||
it 'updates rfc count when soft-solving an rfc' do
|
||||
rfc.full_score_reached = true
|
||||
@ -90,12 +90,12 @@ describe Prometheus::Controller do
|
||||
|
||||
context 'when commenting an rfc' do
|
||||
it 'updates comment metric when commenting an rfc' do
|
||||
FactoryBot.create(:rfc_with_comment)
|
||||
create(:rfc_with_comment)
|
||||
expect(described_class.instance_variable_get(:@rfc_commented_count)).to have_received(:increment).once
|
||||
end
|
||||
|
||||
it 'does not update comment metric when commenting an rfc that already has a comment' do
|
||||
rfc = FactoryBot.create(:rfc_with_comment)
|
||||
rfc = create(:rfc_with_comment)
|
||||
expect(described_class.instance_variable_get(:@rfc_commented_count)).to have_received(:increment).once
|
||||
|
||||
Comment.create(file: rfc.file, user: rfc.user, text: "comment a for rfc #{rfc.question}")
|
||||
|
@ -3,21 +3,21 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Request_for_Comments' do
|
||||
let(:exercise) { FactoryBot.create(:audio_video, description: Forgery(:lorem_ipsum).sentence) }
|
||||
let(:user) { FactoryBot.create(:teacher) }
|
||||
let(:exercise) { create(:audio_video, description: Forgery(:lorem_ipsum).sentence) }
|
||||
let(:user) { create(:teacher) }
|
||||
|
||||
before do
|
||||
visit(sign_in_path)
|
||||
fill_in('email', with: user.email)
|
||||
fill_in('password', with: FactoryBot.attributes_for(:teacher)[:password])
|
||||
fill_in('password', with: attributes_for(:teacher)[:password])
|
||||
click_button(I18n.t('sessions.new.link'))
|
||||
end
|
||||
|
||||
it 'does not contain rfcs for unpublished exercises' do
|
||||
unpublished_rfc = FactoryBot.create(:rfc)
|
||||
unpublished_rfc = create(:rfc)
|
||||
unpublished_rfc.exercise.update(title: 'Unpublished Exercise')
|
||||
unpublished_rfc.exercise.update(unpublished: true)
|
||||
rfc = FactoryBot.create(:rfc)
|
||||
rfc = create(:rfc)
|
||||
rfc.exercise.update(title: 'Normal Exercise')
|
||||
rfc.exercise.update(unpublished: false)
|
||||
|
||||
|
Reference in New Issue
Block a user