spec: change a bunch of before(:all)s to before(:once)

Change-Id: If5437f5e0125c544936f526e7ab4880c62b1e7b3
Reviewed-on: https://gerrit.instructure.com/65757
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Jenkins
Product-Review: James Williams  <jamesw@instructure.com>
QA-Review: James Williams  <jamesw@instructure.com>
This commit is contained in:
James Williams 2015-10-23 13:04:52 -06:00
parent 5de2a36d32
commit 448fcb0f31
19 changed files with 45 additions and 40 deletions

View File

@ -141,7 +141,7 @@ describe Quizzes::QuizSubmissionQuestionsController, :type => :request do
describe 'GET /quiz_submissions/:quiz_submission_id/questions [index]' do
before :all do
before :once do
course_with_student(:active_all => true)
@quiz = @course.quizzes.create!({
title: 'test quiz',
@ -164,9 +164,10 @@ describe Quizzes::QuizSubmissionQuestionsController, :type => :request do
end
describe "with data" do
before :all do
before :once do
create_question_set
end
it 'should list all items' do
Quizzes::QuizSubmission.any_instance.stubs(:quiz_questions).returns([@qq1,@qq2])
json = api_index

View File

@ -1,7 +1,7 @@
require_relative '../../../spec_helper'
describe Api::V1::QuizSubmissionQuestion do
before :all do
before :once do
course_with_student(active_all: true)
@quiz = Quizzes::Quiz.create!(title: "quiz", context: @course)
@quiz_submission = @quiz.generate_submission(@student)

View File

@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
require 'db/migrate/20130617152008_fix_imported_wiki_page_workflow.rb'
describe 'DataFixup::FixImportedWikiPageWorkflow' do
before :all do
before :once do
course
@wiki_pages = []
5.times do |n|

View File

@ -3,7 +3,7 @@ require_relative '../../../app/models/assignment/filter_with_overrides_by_due_at
describe Assignment::FilterWithOverridesByDueAtForStudent do
describe '#filter_assignments' do
before :all do
before :once do
@course = Course.create!
@assignment = @course.assignments.create!
group = @course.grading_period_groups.create!
@ -23,7 +23,7 @@ describe Assignment::FilterWithOverridesByDueAtForStudent do
end
context 'the assignment has one override and the override applies to the student' do
before :all do
before :once do
@assignment.only_visible_to_overrides = true
@override = @assignment.assignment_overrides.create!
@override.assignment_override_students.create!(user: @student)
@ -59,7 +59,7 @@ describe Assignment::FilterWithOverridesByDueAtForStudent do
end
context 'given that override does not have a due at' do
before :all do
before :once do
@override.due_at = nil
@override.save!
end
@ -87,7 +87,7 @@ describe Assignment::FilterWithOverridesByDueAtForStudent do
end
context 'the assignment has one override and the override does not apply to the student' do
before :all do
before :once do
@assignment.assignment_overrides.create!
end
@ -270,7 +270,7 @@ describe Assignment::FilterWithOverridesByDueAtForStudent do
end
context 'the assignment has two overrides that apply to the student' do
before :all do
before :once do
@student_override = @assignment.assignment_overrides.create!
@student_override.assignment_override_students.create!(user: @student)
@ -371,7 +371,7 @@ describe Assignment::FilterWithOverridesByDueAtForStudent do
end
context 'neither override has a due at' do
before :all do
before :once do
@student_override.due_at = nil
@student_override.save!
@section_override.due_at = nil

View File

@ -41,13 +41,13 @@ describe PluginSetting do
expect(s.valid_settings?).to be_falsey
expect(s.settings).to eql({:bar => "qwerty", :foo_enc => "invalid", :foo_salt => "invalid", :foo => PluginSetting::DUMMY_STRING})
end
it "should return default content if no setting is set" do
settings = PluginSetting.settings_for_plugin("plugin_setting_test")
expect(settings).not_to be_nil
expect(settings[:bar]).to eq "asdf"
end
it "should return updated content if created" do
s = PluginSetting.new(:name => "plugin_setting_test", :settings => {:bar => "qwerty"})
expect(s.send(:save_without_callbacks)).to be_truthy
@ -55,14 +55,14 @@ describe PluginSetting do
expect(settings).not_to be_nil
expect(settings[:bar]).to eq "qwerty"
end
it "should return default content if the setting is disabled" do
s = PluginSetting.new(:name => "plugin_setting_test", :settings => {:bar => "qwerty"})
expect(s.send(:save_without_callbacks)).to be_truthy
settings = PluginSetting.settings_for_plugin("plugin_setting_test")
expect(settings).not_to be_nil
expect(settings[:bar]).to eq "qwerty"
s.update_attribute(:disabled, true)
settings = PluginSetting.settings_for_plugin("plugin_setting_test")
expect(settings).not_to be_nil

View File

@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/helpers/gradebook2_common')
describe 'Canvadoc' do
include_context "in-process server selenium tests"
before :all do
before :once do
PluginSetting.create! :name => 'canvadocs',
:settings => {"api_key" => "blahblahblahblahblah",
"base_url" => "http://example.com",

View File

@ -312,7 +312,7 @@ describe "content migrations", :non_parallel do
end
context "course copy" do
before :all do
before :once do
#the "true" param is important, it forces the cache clear
# without it this spec group fails if
# you run it with the whole suite

View File

@ -4,9 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/helpers/discussions_common')
describe "discussion assignments" do
include_context "in-process server selenium tests"
before :all do
Account.default
course_with_teacher_logged_in
before :once do
course_with_teacher(:active_all => true)
@course.assignment_groups.create!(:name => "Assignment Group")
@category1 = @course.group_categories.create!(:name => "category 1")
@category1.configure_self_signup(true, false)
@ -15,9 +14,12 @@ describe "discussion assignments" do
@g1.save!
end
before :each do
user_session(@teacher)
end
context "create group discussion" do
before do
user_session(@teacher)
get "/courses/#{@course.id}/discussion_topics"
expect_new_page_load{f("#new-discussion-btn").click}
f("#discussion-title").send_keys("New Discussion Title")
@ -59,7 +61,6 @@ describe "discussion assignments" do
end
it "should allow the student to reply and teacher to see the unread count", priority: "1", test_id: 150519 do
user_session(@teacher)
get "/courses/#{@course.id}/discussion_topics/#{@discussion_topic.id}"
expect(f('.new-and-total-badge .new-items').text).to include ""
user_session(@student1)

View File

@ -238,7 +238,7 @@ describe "groups" do
#-------------------------------------------------------------------------------------------------------------------
describe "conferences page" do
before(:all) do
before(:once) do
PluginSetting.create!(name: "wimba", settings: {"domain" => "wimba.instructure.com"})
end

View File

@ -198,7 +198,7 @@ describe "groups" do
#-------------------------------------------------------------------------------------------------------------------
describe "conferences page" do
before(:all) do
before(:once) do
PluginSetting.create!(name: "wimba", settings: {"domain" => "wimba.instructure.com"})
end

View File

@ -6,12 +6,15 @@ describe "Notifications" do
include_context "in-process server selenium tests"
context "admin" do
before(:all) do
before(:once) do
course_with_student(active_all: true)
site_admin_logged_in
setup_comm_channel(@student)
end
before :each do
site_admin_logged_in
end
it "should send a notification to users that appointment groups are available", priority: "1", test_id: 186566 do
note_name = 'Appointment Group Published'
setup_notification(@student, name: note_name)

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
include_context 'in-process server selenium tests'
context 'as an observer linked to two students in different sections' do
before(:all) { prepare_vdd_scenario_for_first_observer }
before(:once) { prepare_vdd_scenario_for_first_observer }
before(:each) do
skip('Entire spec context is buggy. Bug tickets created: CNVS-22794 and CNVS-22793')
@ -48,7 +48,7 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
end
context 'as an observer linked to a single student' do
before(:all) { prepare_vdd_scenario_for_second_observer }
before(:once) { prepare_vdd_scenario_for_second_observer }
before(:each) do
user_session(@observer2)
@ -64,4 +64,4 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
"#{format_date_for_view(@unlock_at_b)}")
end
end
end
end

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
include_context 'in-process server selenium tests'
context 'as a student in Section A' do
before(:all) { prepare_vdd_scenario_for_first_student }
before(:once) { prepare_vdd_scenario_for_first_student }
before(:each) do
user_session(@student1)
@ -24,7 +24,7 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
end
context 'as a student in Section B' do
before(:all) { prepare_vdd_scenario_for_second_student }
before(:once) { prepare_vdd_scenario_for_second_student }
before(:each) do
user_session(@student2)

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
include_context 'in-process server selenium tests'
context 'as a TA in both sections' do
before(:all) { prepare_vdd_scenario_for_ta }
before(:once) { prepare_vdd_scenario_for_ta }
before(:each) do
user_session(@ta1)
@ -41,4 +41,4 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
)
end
end
end
end

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
include_context 'in-process server selenium tests'
context 'as a teacher in both sections' do
before(:all) { prepare_vdd_scenario_for_teacher }
before(:once) { prepare_vdd_scenario_for_teacher }
before(:each) do
user_session(@teacher1)
@ -41,4 +41,4 @@ describe 'viewing a quiz with variable due dates on the quizzes index page' do
)
end
end
end
end

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
include_context 'in-process server selenium tests'
context 'as an observer linked to two students in different sections' do
before(:all) { prepare_vdd_scenario_for_first_observer }
before(:once) { prepare_vdd_scenario_for_first_observer }
before(:each) do
user_session(@observer1)
@ -28,7 +28,7 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
end
context 'as an observer linked to a single student' do
before(:all) { prepare_vdd_scenario_for_second_observer }
before(:once) { prepare_vdd_scenario_for_second_observer }
before(:each) do
user_session(@observer2)

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
include_context 'in-process server selenium tests'
context 'as a student in Section A' do
before(:all) { prepare_vdd_scenario_for_first_student }
before(:once) { prepare_vdd_scenario_for_first_student }
before(:each) do
user_session(@student1)
@ -28,7 +28,7 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
end
context 'as a student in Section B' do
before(:all) { prepare_vdd_scenario_for_second_student }
before(:once) { prepare_vdd_scenario_for_second_student }
before(:each) do
user_session(@student2)

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
include_context 'in-process server selenium tests'
context 'as a TA in both sections' do
before(:all) { prepare_vdd_scenario_for_ta }
before(:once) { prepare_vdd_scenario_for_ta }
before(:each) do
user_session(@ta1)

View File

@ -6,7 +6,7 @@ describe 'viewing a quiz with variable due dates on the quiz show page' do
include_context 'in-process server selenium tests'
context 'as a teacher in both sections' do
before(:all) { prepare_vdd_scenario_for_teacher }
before(:once) { prepare_vdd_scenario_for_teacher }
before(:each) do
user_session(@teacher1)