arel-ify specs
refs CNVS-4707 Change-Id: I3b559e6c80d817760e78df47d6c1d7c88f464f2b Reviewed-on: https://gerrit.instructure.com/18984 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Jacob Fugal <jacob@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
79fad58ad1
commit
6dbb42e4da
|
@ -45,7 +45,7 @@ shared_examples_for "file uploads api" do
|
|||
local_storage!
|
||||
# step 1, preflight
|
||||
json = preflight({ :name => filename })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
exemption_string = has_query_exemption? ? ("?quota_exemption=" + attachment.quota_exemption_key) : ""
|
||||
json['upload_url'].should == "http://www.example.com/files_api#{exemption_string}"
|
||||
|
||||
|
@ -56,7 +56,7 @@ shared_examples_for "file uploads api" do
|
|||
post_params = json["upload_params"].merge({"file" => tmpfile})
|
||||
send_multipart(json["upload_url"], post_params)
|
||||
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.should be_deleted
|
||||
exemption_string = has_query_exemption? ? ("quota_exemption=" + attachment.quota_exemption_key + "&") : ""
|
||||
response.should redirect_to("http://www.example.com/api/v1/files/#{attachment.id}/create_success?#{exemption_string}uuid=#{attachment.uuid}")
|
||||
|
@ -98,7 +98,7 @@ shared_examples_for "file uploads api" do
|
|||
# step 1, preflight
|
||||
json = preflight({ :name => filename })
|
||||
json['upload_url'].should == "http://no-bucket.s3.amazonaws.com/"
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
redir = json['upload_params']['success_action_redirect']
|
||||
exemption_string = has_query_exemption? ? ("quota_exemption=" + attachment.quota_exemption_key + "&") : ""
|
||||
redir.should == "http://www.example.com/api/v1/files/#{attachment.id}/create_success?#{exemption_string}uuid=#{attachment.uuid}"
|
||||
|
@ -130,7 +130,7 @@ shared_examples_for "file uploads api" do
|
|||
local_storage!
|
||||
# step 1, preflight
|
||||
json = preflight({ :name => filename, :size => 20, :url => "http://www.example.com/images/delete.png" })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.file_state.should == 'deleted'
|
||||
status_url = json['status_url']
|
||||
status_url.should == "http://www.example.com/api/v1/files/#{attachment.id}/#{attachment.uuid}/status"
|
||||
|
@ -158,7 +158,7 @@ shared_examples_for "file uploads api" do
|
|||
local_storage!
|
||||
# step 1, preflight
|
||||
json = preflight({ :name => filename, :size => 20, :url => '#@$YA#Y#AGWREG' })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
json['status_url'].should == "http://www.example.com/api/v1/files/#{attachment.id}/#{attachment.uuid}/status"
|
||||
|
||||
# step 2, download
|
||||
|
@ -175,7 +175,7 @@ shared_examples_for "file uploads api" do
|
|||
local_storage!
|
||||
# step 1, preflight
|
||||
json = preflight({ :name => filename, :size => 20, :url => '/images/delete.png' })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
json['status_url'].should == "http://www.example.com/api/v1/files/#{attachment.id}/#{attachment.uuid}/status"
|
||||
|
||||
# step 2, download
|
||||
|
@ -194,7 +194,7 @@ shared_examples_for "file uploads api" do
|
|||
# step 1, preflight
|
||||
Canvas::HTTP.expects(:get).with(url).yields(FakeHttpResponse.new(404))
|
||||
json = preflight({ :name => filename, :size => 20, :url => url })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
json['status_url'].should == "http://www.example.com/api/v1/files/#{attachment.id}/#{attachment.uuid}/status"
|
||||
|
||||
# step 2, download
|
||||
|
@ -213,7 +213,7 @@ shared_examples_for "file uploads api" do
|
|||
# step 1, preflight
|
||||
Canvas::HTTP.expects(:get).with(url).raises(Timeout::Error)
|
||||
json = preflight({ :name => filename, :size => 20, :url => url })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
json['status_url'].should == "http://www.example.com/api/v1/files/#{attachment.id}/#{attachment.uuid}/status"
|
||||
|
||||
# step 2, download
|
||||
|
@ -232,7 +232,7 @@ shared_examples_for "file uploads api" do
|
|||
# step 1, preflight
|
||||
Canvas::HTTP.expects(:get).with(url).raises(Canvas::HTTP::TooManyRedirectsError)
|
||||
json = preflight({ :name => filename, :size => 20, :url => url })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.workflow_state.should == 'unattached'
|
||||
json['status_url'].should == "http://www.example.com/api/v1/files/#{attachment.id}/#{attachment.uuid}/status"
|
||||
|
||||
|
@ -256,13 +256,13 @@ shared_examples_for "file uploads api with folders" do
|
|||
|
||||
it "should allow specifying a folder with deprecated argument name" do
|
||||
preflight({ :name => "with_path.txt", :folder => "files/a/b/c/mypath" })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.folder.should == Folder.assert_path("/files/a/b/c/mypath", context)
|
||||
end
|
||||
|
||||
it "should allow specifying a folder" do
|
||||
preflight({ :name => "with_path.txt", :parent_folder_path => "files/a/b/c/mypath" })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.folder.should == Folder.assert_path("/files/a/b/c/mypath", context)
|
||||
end
|
||||
|
||||
|
@ -270,7 +270,7 @@ shared_examples_for "file uploads api with folders" do
|
|||
root = Folder.root_folders(context).first
|
||||
sub = root.sub_folders.create!(:name => "folder1", :context => context)
|
||||
preflight({ :name => "with_path.txt", :parent_folder_id => sub.id.to_param })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.folder_id.should == sub.id
|
||||
end
|
||||
|
||||
|
@ -279,7 +279,7 @@ shared_examples_for "file uploads api with folders" do
|
|||
@folder.should be_present
|
||||
@folder.should be_visible
|
||||
preflight({ :name => "my_essay.doc", :folder => "files/a/b/c/mypath" })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.folder.should == @folder
|
||||
end
|
||||
|
||||
|
@ -296,7 +296,7 @@ shared_examples_for "file uploads api with folders" do
|
|||
send_multipart(json["upload_url"], post_params)
|
||||
post response['Location'], {}, { 'Authorization' => "Bearer #{access_token_for_user @user}" }
|
||||
response.should be_success
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
a1.reload.should be_deleted
|
||||
attachment.reload.should be_available
|
||||
attachment.display_name.should == "test.txt"
|
||||
|
@ -309,7 +309,7 @@ shared_examples_for "file uploads api with folders" do
|
|||
@folder = Folder.assert_path("test", context)
|
||||
a1 = Attachment.create!(:folder => @folder, :context => context, :filename => "test.txt", :uploaded_data => StringIO.new("first"))
|
||||
json = preflight({ :name => "test.txt", :folder => "test", :url => "http://www.example.com/test" })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
Canvas::HTTP.expects(:get).with("http://www.example.com/test").yields(FakeHttpResponse.new(200, "second"))
|
||||
run_jobs
|
||||
|
||||
|
@ -333,7 +333,7 @@ shared_examples_for "file uploads api with folders" do
|
|||
send_multipart(json["upload_url"], post_params)
|
||||
post response['Location'], {}, { 'Authorization' => "Bearer #{access_token_for_user @user}" }
|
||||
response.should be_success
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
a1.reload.should be_available
|
||||
attachment.reload.should be_available
|
||||
a1.display_name.should == "test.txt"
|
||||
|
@ -346,7 +346,7 @@ shared_examples_for "file uploads api with folders" do
|
|||
@folder = Folder.assert_path("test", context)
|
||||
a1 = Attachment.create!(:folder => @folder, :context => context, :filename => "test.txt", :uploaded_data => StringIO.new("first"))
|
||||
json = preflight({ :name => "test.txt", :folder => "test", :on_duplicate => 'rename', :url => "http://www.example.com/test" })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
Canvas::HTTP.expects(:get).with("http://www.example.com/test").yields(FakeHttpResponse.new(200, "second"))
|
||||
run_jobs
|
||||
|
||||
|
@ -364,7 +364,7 @@ shared_examples_for "file uploads api with folders" do
|
|||
json = preflight({ :name => "test.txt", :folder => "test", :on_duplicate => 'rename' })
|
||||
|
||||
redir = json['upload_params']['success_action_redirect']
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
AWS::S3::S3Object.any_instance.expects(:head).returns({
|
||||
:content_type => 'application/msword',
|
||||
:content_length => 1234,
|
||||
|
@ -387,7 +387,7 @@ shared_examples_for "file uploads api with quotas" do
|
|||
@context.write_attribute(:storage_quota, 5.megabytes)
|
||||
@context.save!
|
||||
json = preflight({ :name => "test.txt", :size => 3.megabytes })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.workflow_state.should == 'unattached'
|
||||
attachment.filename.should == 'test.txt'
|
||||
end
|
||||
|
@ -458,7 +458,7 @@ shared_examples_for "file uploads api with quotas" do
|
|||
@context.save!
|
||||
json = preflight({ :name => "test.txt", :url => "http://www.example.com/test" })
|
||||
status_url = json['status_url']
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
Canvas::HTTP.expects(:get).with("http://www.example.com/test").yields(FakeHttpResponse.new(200, (" " * 2.megabytes)))
|
||||
run_jobs
|
||||
|
||||
|
@ -474,7 +474,7 @@ shared_examples_for "file uploads api without quotas" do
|
|||
@context.write_attribute(:storage_quota, 0)
|
||||
@context.save!
|
||||
json = preflight({ :name => "test.txt", :size => 1.megabyte })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
json['upload_url'].should match(/#{attachment.quota_exemption_key}/)
|
||||
end
|
||||
it "should ignore context-related quotas in preflight" do
|
||||
|
@ -482,7 +482,7 @@ shared_examples_for "file uploads api without quotas" do
|
|||
@context.write_attribute(:storage_quota, 0)
|
||||
@context.save!
|
||||
json = preflight({ :name => "test.txt", :size => 1.megabyte })
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
json['upload_params']['success_action_redirect'].should match(/#{attachment.quota_exemption_key}/)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -66,7 +66,7 @@ describe "API", :type => :integration do
|
|||
response.should be_success
|
||||
response.header['content-type'].should == 'application/json; charset=utf-8'
|
||||
|
||||
@assignment = @course.assignments.last(:order => :id)
|
||||
@assignment = @course.assignments.order(:id).last
|
||||
@assignment.title.should == "test assignment"
|
||||
@assignment.points_possible.should == 15
|
||||
end
|
||||
|
@ -77,7 +77,7 @@ describe "API", :type => :integration do
|
|||
response.should be_success
|
||||
response.header['content-type'].should == 'application/json; charset=utf-8'
|
||||
|
||||
@assignment = @course.assignments.last(:order => :id)
|
||||
@assignment = @course.assignments.order(:id).last
|
||||
@assignment.title.should == "test assignment"
|
||||
@assignment.points_possible.should == 15
|
||||
end
|
||||
|
|
|
@ -489,7 +489,7 @@ describe AssignmentsApiController, :type => :integration do
|
|||
find_or_create_by_notification_id(@notification.id).
|
||||
update_attribute(:frequency, 'immediately')
|
||||
@assignment = @course.assignments.create!
|
||||
Assignment.update_all({:created_at => Time.zone.now - 1.day}, {:id => @assignment.id})
|
||||
Assignment.where(:id => @assignment).update_all(:created_at => Time.zone.now - 1.day)
|
||||
@adhoc_due_at = 5.days.from_now
|
||||
@section_due_at = 7.days.from_now
|
||||
@params = {
|
||||
|
|
|
@ -36,7 +36,7 @@ describe "Collections API", :type => :integration do
|
|||
:name => "test3",
|
||||
:visibility => 'public',
|
||||
})
|
||||
@c3 = Collection.last(:order => :id)
|
||||
@c3 = Collection.order(:id).last
|
||||
json.should == collection_json(@c3).merge({
|
||||
'id' => @c3.id,
|
||||
'name' => 'test3',
|
||||
|
@ -241,7 +241,7 @@ describe "Collections API", :type => :integration do
|
|||
describe "item creation" do
|
||||
it "should allow creating from a http url" do
|
||||
json = api_call(:post, @c1_items_path, @c1_items_path_options.merge(:action => "create"), { :link_url => "http://www.example.com/a/b/c", :user_comment => 'new item' })
|
||||
new_item = @c1.collection_items.last(:order => :id)
|
||||
new_item = @c1.collection_items.order(:id).last
|
||||
new_item.collection_item_data.link_url.should == "http://www.example.com/a/b/c"
|
||||
new_item.user.should == @user
|
||||
end
|
||||
|
@ -249,7 +249,7 @@ describe "Collections API", :type => :integration do
|
|||
it "should allow cloning an existing item" do
|
||||
json = api_call(:post, @c1_items_path, @c1_items_path_options.merge(:action => "create"), { :link_url => "http://localhost/api/v1/collections/items/#{@i3.id}", :user_comment => 'cloned' })
|
||||
json['post_count'].should == 3
|
||||
new_item = @c1.collection_items.last(:order => :id)
|
||||
new_item = @c1.collection_items.order(:id).last
|
||||
new_item.collection_item_data.should == @i3.collection_item_data
|
||||
new_item.user.should == @user
|
||||
end
|
||||
|
@ -604,7 +604,7 @@ describe "Collections API", :type => :integration do
|
|||
|
||||
it "should allow creating a new item" do
|
||||
json = api_call(:post, @c1_items_path, @c1_items_path_options.merge(:action => "create"), { :link_url => "http://www.example.com/a/b/c", :user_comment => 'new item' })
|
||||
new_item = @c1.collection_items.last(:order => :id)
|
||||
new_item = @c1.collection_items.order(:id).last
|
||||
new_item.collection_item_data.link_url.should == "http://www.example.com/a/b/c"
|
||||
new_item.user.should == @user
|
||||
end
|
||||
|
|
|
@ -395,7 +395,7 @@ describe ConversationsController, :type => :integration do
|
|||
p.delete("avatar_url")
|
||||
}
|
||||
}
|
||||
conversation = @me.all_conversations.scoped(:order => "conversation_id DESC").first
|
||||
conversation = @me.all_conversations.order("conversation_id DESC").first
|
||||
json.should eql [
|
||||
{
|
||||
"id" => conversation.conversation_id,
|
||||
|
@ -436,7 +436,7 @@ describe ConversationsController, :type => :integration do
|
|||
p.delete("avatar_url")
|
||||
}
|
||||
}
|
||||
conversation = @me.all_conversations.scoped(:order => "conversation_id DESC").first
|
||||
conversation = @me.all_conversations.order("conversation_id DESC").first
|
||||
json.should eql [
|
||||
{
|
||||
"id" => conversation.conversation_id,
|
||||
|
@ -568,7 +568,7 @@ describe ConversationsController, :type => :integration do
|
|||
p.delete("avatar_url")
|
||||
}
|
||||
}
|
||||
conversation = @me.all_conversations.scoped(:order => "last_message_at DESC, conversation_id DESC").first
|
||||
conversation = @me.all_conversations.order("last_message_at DESC, conversation_id DESC").first
|
||||
json.should eql [
|
||||
{
|
||||
"id" => conversation.conversation_id,
|
||||
|
|
|
@ -1593,7 +1593,7 @@ describe ContentImportsController, :type => :integration do
|
|||
{ :controller => 'content_imports', :action => 'copy_course_content', :course_id => to_id, :format => 'json' },
|
||||
{:source_course => from_id}.merge(options))
|
||||
|
||||
cm = ContentMigration.last(:order => :id)
|
||||
cm = ContentMigration.order(:id).last
|
||||
data.should == {
|
||||
'id' => cm.id,
|
||||
'progress' => nil,
|
||||
|
|
|
@ -104,7 +104,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
api_call(:post, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "create", :format => "json", :course_id => @course.to_param },
|
||||
{ :title => "test title", :message => "test <b>message</b>" })
|
||||
@topic = @course.discussion_topics.last(:order => :id)
|
||||
@topic = @course.discussion_topics.order(:id).last
|
||||
@topic.title.should == "test title"
|
||||
@topic.message.should == "test <b>message</b>"
|
||||
@topic.threaded?.should be_false
|
||||
|
@ -118,7 +118,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
api_call(:post, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "create", :format => "json", :course_id => @course.to_param },
|
||||
{ :title => "test title", :message => "test <b>message</b>", :is_announcement => true })
|
||||
@topic = @course.announcements.last(:order => :id)
|
||||
@topic = @course.announcements.order(:id).last
|
||||
@topic.title.should == "test title"
|
||||
@topic.message.should == "test <b>message</b>"
|
||||
end
|
||||
|
@ -128,7 +128,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
api_call(:post, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "create", :format => "json", :course_id => @course.to_param },
|
||||
{ :title => "test title", :message => "test <b>message</b>", :discussion_type => "threaded", :delayed_post_at => post_at.as_json, :podcast_has_student_posts => '1', :require_initial_post => '1' })
|
||||
@topic = @course.discussion_topics.last(:order => :id)
|
||||
@topic = @course.discussion_topics.order(:id).last
|
||||
@topic.title.should == "test title"
|
||||
@topic.message.should == "test <b>message</b>"
|
||||
@topic.threaded?.should == true
|
||||
|
@ -144,7 +144,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
api_call(:post, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "create", :format => "json", :course_id => @course.to_param },
|
||||
{ :title => "test title", :message => "test <b>message</b>", :assignment => { :points_possible => 15, :grading_type => "percent", :due_at => due_date.as_json, :name => "override!" } })
|
||||
@topic = @course.discussion_topics.last(:order => :id)
|
||||
@topic = @course.discussion_topics.order(:id).last
|
||||
@topic.title.should == "test title"
|
||||
@topic.assignment.should be_present
|
||||
@topic.assignment.points_possible.should == 15
|
||||
|
@ -158,7 +158,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
api_call(:post, "/api/v1/courses/#{@course.id}/discussion_topics",
|
||||
{ :controller => "discussion_topics", :action => "create", :format => "json", :course_id => @course.to_param },
|
||||
{ :title => "test title", :message => "test <b>message</b>", :assignment => { :set_assignment => 'false' } })
|
||||
@topic = @course.discussion_topics.last(:order => :id)
|
||||
@topic = @course.discussion_topics.order(:id).last
|
||||
@topic.title.should == "test title"
|
||||
@topic.assignment.should be_nil
|
||||
end
|
||||
|
@ -1231,7 +1231,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
{ :controller => "discussion_topics_api", :action => "add_reply", :format => "json", :course_id => @course.id.to_s, :topic_id => @topic.id.to_s, :entry_id => @sub2.id.to_s },
|
||||
{ :message => "ohai" })
|
||||
json['parent_id'].should == @sub2.id
|
||||
@sub4 = DiscussionEntry.last(:order => :id)
|
||||
@sub4 = DiscussionEntry.order(:id).last
|
||||
@sub4.id.should == json['id']
|
||||
|
||||
json = api_call(:get, "/api/v1/courses/#{@course.id}/discussion_topics/#{@topic.id}/entries/#{@entry.id}/replies",
|
||||
|
@ -1507,7 +1507,7 @@ describe DiscussionTopicsController, :type => :integration do
|
|||
end
|
||||
|
||||
it "should mark entries as read on a collection item" do
|
||||
Collection.update_all({ :visibility => 'public' }, { :id => @collection.id })
|
||||
Collection.where(:id => @collection).update_all(:visibility => 'public')
|
||||
@collection.reload
|
||||
topic = @item.discussion_topic
|
||||
topic.save!
|
||||
|
|
|
@ -452,7 +452,7 @@ describe EnrollmentsApiController, :type => :integration do
|
|||
|
||||
it "should list all of a user's enrollments in an account" do
|
||||
json = api_call(:get, @user_path, @user_params)
|
||||
enrollments = @student.current_enrollments.scoped(:include => :user, :order => 'users.sortable_name ASC')
|
||||
enrollments = @student.current_enrollments.includes(:user).order("users.sortable_name ASC")
|
||||
json.should == enrollments.map { |e|
|
||||
{
|
||||
'root_account_id' => e.root_account_id,
|
||||
|
@ -599,7 +599,7 @@ describe EnrollmentsApiController, :type => :integration do
|
|||
@user = current_user
|
||||
json = api_call(:get, @path, @params)
|
||||
enrollments = %w{observer student ta teacher}.inject([]) do |res, type|
|
||||
res = res + @course.send("#{type}_enrollments").scoped(:include => :user, :order => 'users.sortable_name ASC')
|
||||
res = res + @course.send("#{type}_enrollments").includes(:user).order("users.sortable_name ASC")
|
||||
end
|
||||
json.should == enrollments.map { |e|
|
||||
h = {
|
||||
|
@ -646,7 +646,7 @@ describe EnrollmentsApiController, :type => :integration do
|
|||
|
||||
it "should list its own enrollments" do
|
||||
json = api_call(:get, @user_path, @user_params)
|
||||
enrollments = @user.current_enrollments.scoped(:include => :user, :order => 'users.sortable_name ASC')
|
||||
enrollments = @user.current_enrollments.includes(:user).order("users.sortable_name ASC")
|
||||
json.should == enrollments.map { |e|
|
||||
{
|
||||
'root_account_id' => e.root_account_id,
|
||||
|
@ -729,7 +729,7 @@ describe EnrollmentsApiController, :type => :integration do
|
|||
it "should include users' sis and login ids" do
|
||||
json = api_call(:get, @path, @params)
|
||||
enrollments = %w{observer student ta teacher}.inject([]) do |res, type|
|
||||
res = res + @course.send("#{type}_enrollments").scoped(:include => :user)
|
||||
res = res + @course.send("#{type}_enrollments").includes(:user)
|
||||
end
|
||||
json.should == enrollments.map do |e|
|
||||
user_json = {
|
||||
|
@ -788,7 +788,7 @@ describe EnrollmentsApiController, :type => :integration do
|
|||
it "should properly paginate" do
|
||||
json = api_call(:get, "#{@path}?page=1&per_page=1", @params.merge(:page => 1.to_param, :per_page => 1.to_param))
|
||||
enrollments = %w{observer student ta teacher}.inject([]) { |res, type|
|
||||
res = res + @course.send("#{type}_enrollments").scoped(:include => :user)
|
||||
res = res + @course.send("#{type}_enrollments").includes(:user)
|
||||
}.map do |e|
|
||||
h = {
|
||||
'root_account_id' => e.root_account_id,
|
||||
|
|
|
@ -381,7 +381,7 @@ describe "Folders API", :type => :integration do
|
|||
api_call(:post, "/api/v1/folders/#{@root_folder.id}/files",
|
||||
{ :controller => "folders", :action => "create_file", :format => "json", :folder_id => @root_folder.id.to_param, },
|
||||
:name => "with_path.txt")
|
||||
attachment = Attachment.last(:order => :id)
|
||||
attachment = Attachment.order(:id).last
|
||||
attachment.folder_id.should == @root_folder.id
|
||||
end
|
||||
end
|
||||
|
|
|
@ -129,7 +129,7 @@ describe "Groups API", :type => :integration do
|
|||
'is_public'=> false,
|
||||
'join_level'=> "parent_context_request",
|
||||
})
|
||||
@community2 = Group.last(:order => :id)
|
||||
@community2 = Group.order(:id).last
|
||||
@community2.group_category.should be_communities
|
||||
json.should == group_json(@community2, @user)
|
||||
end
|
||||
|
@ -295,7 +295,7 @@ describe "Groups API", :type => :integration do
|
|||
:filter_states => ["invited"]
|
||||
})
|
||||
json.count.should == 1
|
||||
json.first.should == membership_json(@community.group_memberships.scoped(:conditions => { :workflow_state => 'invited' }).first)
|
||||
json.first.should == membership_json(@community.group_memberships.where(:workflow_state => 'invited').first)
|
||||
end
|
||||
|
||||
it "should allow someone to request to join a group" do
|
||||
|
@ -305,7 +305,7 @@ describe "Groups API", :type => :integration do
|
|||
json = api_call(:post, @memberships_path, @memberships_path_options.merge(:group_id => @community.to_param, :action => "create"), {
|
||||
:user_id => @user.id
|
||||
})
|
||||
@membership = GroupMembership.scoped(:conditions => { :user_id => @user.id, :group_id => @community.id }).first
|
||||
@membership = GroupMembership.where(:user_id => @user, :group_id => @community).first
|
||||
@membership.workflow_state.should == "requested"
|
||||
json.should == membership_json(@membership)
|
||||
end
|
||||
|
@ -317,7 +317,7 @@ describe "Groups API", :type => :integration do
|
|||
json = api_call(:post, @memberships_path, @memberships_path_options.merge(:group_id => @community.to_param, :action => "create"), {
|
||||
:user_id => @user.id
|
||||
})
|
||||
@membership = GroupMembership.scoped(:conditions => { :user_id => @user.id, :group_id => @community.id }).first
|
||||
@membership = GroupMembership.where(:user_id => @user, :group_id => @community).first
|
||||
@membership.workflow_state.should == "accepted"
|
||||
json.should == membership_json(@membership)
|
||||
end
|
||||
|
@ -401,16 +401,16 @@ describe "Groups API", :type => :integration do
|
|||
|
||||
it "should allow someone to leave a group" do
|
||||
@user = @member
|
||||
@gm = @community.group_memberships.scoped(:conditions => { :user_id => @user.id }).first
|
||||
@gm = @community.group_memberships.where(:user_id => @user).first
|
||||
api_call(:delete, "#{@memberships_path}/#{@gm.id}", @memberships_path_options.merge(:group_id => @community.to_param, :membership_id => @gm.to_param, :action => "destroy"))
|
||||
@membership = GroupMembership.scoped(:conditions => { :user_id => @user.id, :group_id => @community.id }).first
|
||||
@membership = GroupMembership.where(:user_id => @user, :group_id => @community).first
|
||||
@membership.workflow_state.should == "deleted"
|
||||
end
|
||||
|
||||
it "should allow leaving a group using 'self'" do
|
||||
@user = @member
|
||||
api_call(:delete, "#{@memberships_path}/self", @memberships_path_options.merge(:group_id => @community.to_param, :membership_id => 'self', :action => "destroy"))
|
||||
@membership = GroupMembership.scoped(:conditions => { :user_id => @user.id, :group_id => @community.id }).first
|
||||
@membership = GroupMembership.where(:user_id => @user, :group_id => @community).first
|
||||
@membership.workflow_state.should == "deleted"
|
||||
end
|
||||
|
||||
|
@ -420,7 +420,7 @@ describe "Groups API", :type => :integration do
|
|||
expect {
|
||||
@json = api_call(:post, "#{@community_path}/invite", @category_path_options.merge(:group_id => @community.to_param, :action => "invite"), invitees)
|
||||
}.to change(User, :count).by(2)
|
||||
@memberships = @community.reload.group_memberships.scoped(:conditions => { :workflow_state => "invited" }, :order => :id).all
|
||||
@memberships = @community.reload.group_memberships.where(:workflow_state => "invited").order(:id).all
|
||||
@memberships.count.should == 2
|
||||
@json.sort{ |a,b| a['id'] <=> b['id'] }.should == @memberships.map{ |gm| membership_json(gm) }
|
||||
end
|
||||
|
@ -429,7 +429,7 @@ describe "Groups API", :type => :integration do
|
|||
@user = @member
|
||||
invitees = { :invitees => ["leonard@example.com", "sheldon@example.com"] }
|
||||
api_call(:post, "#{@community_path}/invite", @category_path_options.merge(:group_id => @community.to_param, :action => "invite"), invitees, {}, :expected_status => 401)
|
||||
@memberships = @community.reload.group_memberships.scoped(:conditions => { :workflow_state => "invited" }, :order => :id).count.should == 0
|
||||
@memberships = @community.reload.group_memberships.where(:workflow_state => "invited").order(:id).count.should == 0
|
||||
end
|
||||
|
||||
it "should find people when inviting to a group in a non-default account" do
|
||||
|
@ -467,7 +467,7 @@ describe "Groups API", :type => :integration do
|
|||
@memberships_path_options.merge(:group_id => @group.to_param, :action => "create"),
|
||||
{ :user_id => @to_add.id })
|
||||
|
||||
@membership = GroupMembership.scoped(:conditions => { :user_id => @to_add.id, :group_id => @group.id }).first
|
||||
@membership = GroupMembership.where(:user_id => @to_add, :group_id => @group).first
|
||||
@membership.workflow_state.should == "accepted"
|
||||
json.should == membership_json(@membership)
|
||||
end
|
||||
|
|
|
@ -46,7 +46,7 @@ describe UsersController, :type => :integration do
|
|||
@context = @course
|
||||
@topic1 = discussion_topic_model
|
||||
# introduce a dangling StreamItemInstance
|
||||
StreamItem.delete_all(:id => @user.visible_stream_item_instances.last.stream_item_id)
|
||||
StreamItem.where(:id => @user.visible_stream_item_instances.last.stream_item_id).delete_all
|
||||
json = api_call(:get, "/api/v1/users/activity_stream.json",
|
||||
{ :controller => "users", :action => "activity_stream", :format => 'json' })
|
||||
json.size.should == 1
|
||||
|
|
|
@ -26,14 +26,14 @@ describe 'Submissions API', :type => :integration do
|
|||
@submit_homework_time += 1.hour
|
||||
sub = assignment.find_or_create_submission(student)
|
||||
if sub.versions.size == 1
|
||||
Version.update_all({:created_at => @submit_homework_time}, {:id => sub.versions.first.id})
|
||||
Version.where(:id => sub.versions.first).update_all(:created_at => @submit_homework_time)
|
||||
end
|
||||
sub.workflow_state = 'submitted'
|
||||
yield(sub) if block_given?
|
||||
sub.with_versioning(:explicit => true) do
|
||||
update_with_protected_attributes!(sub, { :submitted_at => @submit_homework_time, :created_at => @submit_homework_time }.merge(opts))
|
||||
end
|
||||
sub.versions(true).each { |v| Version.update_all({ :created_at => v.model.created_at }, { :id => v.id }) }
|
||||
sub.versions(true).each { |v| Version.where(:id => v).update_all(:created_at => v.model.created_at) }
|
||||
sub
|
||||
end
|
||||
|
||||
|
@ -140,7 +140,7 @@ describe 'Submissions API', :type => :integration do
|
|||
}.to change { Delayed::Job.jobs_count(:current) }.by(1)
|
||||
|
||||
Submission.count.should == 2
|
||||
@submission = Submission.last(:order => :id)
|
||||
@submission = Submission.order(:id).last
|
||||
@submission.grader.should == @teacher
|
||||
|
||||
json['score'].should == 7.5
|
||||
|
@ -1213,7 +1213,7 @@ describe 'Submissions API', :type => :integration do
|
|||
:course_id => @course.to_param, :assignment_id => assignment.to_param,
|
||||
:id => student.to_param },
|
||||
{ :comment => { :text_comment => 'hidden comment' } })
|
||||
submission.submission_comments.scoped(:order => 'id DESC').first.should be_hidden
|
||||
submission.submission_comments.order("id DESC").first.should be_hidden
|
||||
end
|
||||
|
||||
it "should not hide student comments on muted assignments" do
|
||||
|
@ -1229,7 +1229,7 @@ describe 'Submissions API', :type => :integration do
|
|||
:course_id => @course.to_param, :assignment_id => assignment.to_param,
|
||||
:id => student.to_param },
|
||||
{ :comment => { :text_comment => 'hidden comment' } })
|
||||
submission.submission_comments.scoped(:order => 'id DESC').first.should_not be_hidden
|
||||
submission.submission_comments.order("id DESC").first.should_not be_hidden
|
||||
end
|
||||
|
||||
it "should allow submitting points" do
|
||||
|
|
|
@ -260,7 +260,7 @@ describe "Users API", :type => :integration do
|
|||
users << User.create!(:name => u[0])
|
||||
users[i].pseudonyms.create!(:unique_id => u[1], :account => @account) { |p| p.sis_user_id = u[1] }
|
||||
end
|
||||
@account.all_users.scoped(:order => :sortable_name).each_with_index do |user, i|
|
||||
@account.all_users.order(:sortable_name).each_with_index do |user, i|
|
||||
next unless users.find { |u| u == user }
|
||||
json = api_call(:get, "/api/v1/accounts/#{@account.id}/users",
|
||||
{ :controller => 'users', :action => 'index', :account_id => @account.id.to_param, :format => 'json' },
|
||||
|
|
|
@ -603,14 +603,14 @@ describe GroupsController do
|
|||
get 'accept_invitation', :group_id => @group.id, :uuid => @membership.uuid
|
||||
@group.reload
|
||||
@group.has_member?(@user).should be_true
|
||||
@group.group_memberships.scoped(:conditions => {:workflow_state => "invited"}).count.should == 0
|
||||
@group.group_memberships.where(:workflow_state => "invited").count.should == 0
|
||||
end
|
||||
|
||||
it "should reject an invalid invitation uuid" do
|
||||
get 'accept_invitation', :group_id => @group.id, :uuid => @membership.uuid + "x"
|
||||
@group.reload
|
||||
@group.has_member?(@user).should be_false
|
||||
@group.group_memberships.scoped(:conditions => {:workflow_state => "invited"}).count.should == 1
|
||||
@group.group_memberships.where(:workflow_state => "invited").count.should == 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -91,7 +91,7 @@ describe QuizSubmissionsController do
|
|||
course_with_student(:active_all => true)
|
||||
quiz_model(:course => @course)
|
||||
@qs = @quiz.generate_submission(@student, false)
|
||||
QuizSubmission.update_all({ :updated_at => 1.hour.ago }, { :id => @qs.id })
|
||||
QuizSubmission.where(:id => @qs).update_all(:updated_at => 1.hour.ago)
|
||||
|
||||
put 'backup', :quiz_id => @quiz.id, :course_id => @course.id, :a => 'test'
|
||||
response.status.to_i.should == 401
|
||||
|
@ -103,7 +103,7 @@ describe QuizSubmissionsController do
|
|||
course_with_student_logged_in(:active_all => true)
|
||||
quiz_model(:course => @course)
|
||||
@qs = @quiz.generate_submission(@student, false)
|
||||
QuizSubmission.update_all({ :updated_at => 1.hour.ago }, { :id => @qs.id })
|
||||
QuizSubmission.where(:id => @qs).update_all(:updated_at => 1.hour.ago)
|
||||
|
||||
put 'backup', :quiz_id => @quiz.id, :course_id => @course.id, :a => 'test'
|
||||
response.should be_success
|
||||
|
|
|
@ -428,7 +428,7 @@ describe UsersController do
|
|||
post 'create', :format => 'json', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com', :send_confirmation => '0' }, :user => { :name => 'Jacob Fugal' }
|
||||
response.should be_success
|
||||
p = Pseudonym.find_by_unique_id('jacob@instructure.com')
|
||||
Message.find(:first, :conditions => { :communication_channel_id => p.user.email_channel.id, :notification_id => notification.id }).should_not be_nil
|
||||
Message.where(:communication_channel_id => p.user.email_channel, :notification_id => notification).first.should_not be_nil
|
||||
end
|
||||
|
||||
it "should not notify the user if the merge opportunity can't log in'" do
|
||||
|
@ -445,7 +445,7 @@ describe UsersController do
|
|||
post 'create', :format => 'json', :account_id => account.id, :pseudonym => { :unique_id => 'jacob@instructure.com', :send_confirmation => '0' }, :user => { :name => 'Jacob Fugal' }
|
||||
response.should be_success
|
||||
p = Pseudonym.find_by_unique_id('jacob@instructure.com')
|
||||
Message.find(:first, :conditions => { :communication_channel_id => p.user.email_channel.id, :notification_id => notification.id }).should be_nil
|
||||
Message.where(:communication_channel_id => p.user.email_channel, :notification_id => notification).first.should be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -380,7 +380,7 @@ describe ApplicationHelper do
|
|||
# verify it's not overly long
|
||||
key1.length.should <= 40
|
||||
|
||||
User.update_all({ :updated_at => 1.hour.ago }, { :id => collection[1].id })
|
||||
User.where(:id => collection[1]).update_all(:updated_at => 1.hour.ago)
|
||||
collection[1].reload
|
||||
key3 = collection_cache_key(collection)
|
||||
key1.should_not == key3
|
||||
|
|
|
@ -62,13 +62,13 @@ describe "user asset accesses" do
|
|||
html.css('#usage_report .access.assignment .readable_name').text.strip.should == 'Assignment 1'
|
||||
html.css('#usage_report .access.assignment .view_score').text.strip.should == '1'
|
||||
html.css('#usage_report .access.assignment .last_viewed').text.strip.should == datetime_string(now)
|
||||
AssetUserAccess.first(:conditions => { :user_id => @student.id }).last_access.to_i.should == now.to_i
|
||||
AssetUserAccess.where(:user_id => @student).first.last_access.to_i.should == now.to_i
|
||||
|
||||
now2 = now + 1.hour
|
||||
Time.stubs(:now).returns(now2)
|
||||
|
||||
# make sure that we're not using the uodated_at time as the time of the access
|
||||
AssetUserAccess.update_all({ :updated_at => now2 + 5.hours }, { :user_id => @student.id })
|
||||
AssetUserAccess.where(:user_id => @student).update_all(:updated_at => now2 + 5.hours)
|
||||
|
||||
user_session(@student)
|
||||
get "/courses/#{@course.id}/assignments/#{assignment.id}"
|
||||
|
@ -82,6 +82,6 @@ describe "user asset accesses" do
|
|||
html.css('#usage_report .access.assignment .readable_name').text.strip.should == 'Assignment 1'
|
||||
html.css('#usage_report .access.assignment .view_score').text.strip.should == '2'
|
||||
html.css('#usage_report .access.assignment .last_viewed').text.strip.should == datetime_string(now2)
|
||||
AssetUserAccess.first(:conditions => { :user_id => @student.id }).last_access.to_i.should == now2.to_i
|
||||
AssetUserAccess.where(:user_id => @student).first.last_access.to_i.should == now2.to_i
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ describe ContextModule do
|
|||
course_with_teacher_logged_in(:active_all => true)
|
||||
context_module = @course.context_modules.create!
|
||||
content_tag = context_module.add_item :type => 'context_module_sub_header', :title => "My Sub Header Title"
|
||||
ContextModule.update_all({ :updated_at => 1.hour.ago }, { :id => context_module.id })
|
||||
ContextModule.where(:id => context_module).update_all(:updated_at => 1.hour.ago)
|
||||
get "/courses/#{@course.id}/modules"
|
||||
response.body.should match(/My Sub Header Title/)
|
||||
|
||||
|
|
|
@ -31,15 +31,15 @@ describe "BookmarkedCollection::MergeProxy" do
|
|||
def self.restrict_scope(scope, pager)
|
||||
if bookmark = pager.current_bookmark
|
||||
comparison = (pager.include_bookmark ? 'courses.id >= ?' : 'courses.id > ?')
|
||||
scope = scope.scoped(:conditions => [comparison, bookmark])
|
||||
scope = scope.where(comparison, bookmark)
|
||||
end
|
||||
scope.scoped(:order => "courses.id ASC")
|
||||
scope.order("courses.id ASC")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#paginate" do
|
||||
before :each do
|
||||
@scope = Course.scoped(:order => :id)
|
||||
@scope = Course.order(:id)
|
||||
3.times{ @scope.create! }
|
||||
@collection = BookmarkedCollection.wrap(MyBookmarker, @scope)
|
||||
@proxy = BookmarkedCollection::MergeProxy.new([['label', @collection]])
|
||||
|
@ -85,8 +85,8 @@ describe "BookmarkedCollection::MergeProxy" do
|
|||
|
||||
describe "with multiple collections" do
|
||||
before :each do
|
||||
@created_scope = Course.scoped(:conditions => {:workflow_state => 'created'})
|
||||
@deleted_scope = Course.scoped(:conditions => {:workflow_state => 'deleted'})
|
||||
@created_scope = Course.where(:workflow_state => 'created')
|
||||
@deleted_scope = Course.where(:workflow_state => 'deleted')
|
||||
|
||||
Course.delete_all
|
||||
@courses = [
|
||||
|
@ -161,8 +161,8 @@ describe "BookmarkedCollection::MergeProxy" do
|
|||
before :each do
|
||||
Course.delete_all
|
||||
@courses = 6.times.map{ Course.create! }
|
||||
@scope1 = Course.scoped(:select => "id, 1 as scope", :conditions => ['id < ?', @courses[4].id])
|
||||
@scope2 = Course.scoped(:select => "id, 2 as scope", :conditions => ['id > ?', @courses[1].id])
|
||||
@scope1 = Course.select("id, 1 as scope").where("id<?", @courses[4].id)
|
||||
@scope2 = Course.select("id, 2 as scope").where("id>?", @courses[1].id)
|
||||
|
||||
@collection1 = BookmarkedCollection.wrap(MyBookmarker, @scope1)
|
||||
@collection2 = BookmarkedCollection.wrap(MyBookmarker, @scope2)
|
||||
|
|
|
@ -21,7 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|||
describe "BookmarkedCollection::Proxy" do
|
||||
describe "#paginate" do
|
||||
before :each do
|
||||
@scope = Course.scoped(:order => :id)
|
||||
@scope = Course.order(:id)
|
||||
3.times{ @scope.create! }
|
||||
|
||||
@next_bookmark = stub
|
||||
|
|
|
@ -32,9 +32,9 @@ describe "BookmarkedCollection" do
|
|||
def self.restrict_scope(scope, pager)
|
||||
if bookmark = pager.current_bookmark
|
||||
comparison = (pager.include_bookmark ? 'id >= ?' : 'id > ?')
|
||||
scope = scope.scoped(:conditions => [comparison, bookmark])
|
||||
scope = scope.where(comparison, bookmark)
|
||||
end
|
||||
scope.scoped(:order => "id ASC")
|
||||
scope.order("id ASC")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -50,9 +50,9 @@ describe "BookmarkedCollection" do
|
|||
def self.restrict_scope(scope, pager)
|
||||
if bookmark = pager.current_bookmark
|
||||
comparison = (pager.include_bookmark ? 'name >= ?' : 'name > ?')
|
||||
scope = scope.scoped(:conditions => [comparison, bookmark])
|
||||
scope = scope.where(comparison, bookmark)
|
||||
end
|
||||
scope.scoped(:order => "name ASC")
|
||||
scope.order("name ASC")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -80,8 +80,8 @@ describe "BookmarkedCollection" do
|
|||
end
|
||||
|
||||
it "should use the bookmarker's bookmark applicator to restrict by bookmark" do
|
||||
bookmark = @scope.scoped(:order => 'courses.id').first.id
|
||||
bookmarked_scope = @scope.scoped(:order => 'courses.id', :conditions => ['courses.id > ?', bookmark])
|
||||
bookmark = @scope.order("courses.id").first.id
|
||||
bookmarked_scope = @scope.order("courses.id").where("courses.id>?", bookmark)
|
||||
IDBookmarker.stubs(:restrict_scope).returns(bookmarked_scope)
|
||||
|
||||
collection = BookmarkedCollection.wrap(IDBookmarker, @scope)
|
||||
|
@ -97,11 +97,11 @@ describe "BookmarkedCollection" do
|
|||
end
|
||||
|
||||
it "should apply any restriction block given to the scope" do
|
||||
course = @scope.scoped(:order => 'courses.id').last
|
||||
course = @scope.order("courses.id").last
|
||||
course.update_attributes(:name => 'Matching Name')
|
||||
|
||||
collection = BookmarkedCollection.wrap(IDBookmarker, @scope) do |scope|
|
||||
scope.scoped(:conditions => {:name => course.name})
|
||||
scope.where(:name => course.name)
|
||||
end
|
||||
|
||||
collection.paginate(:per_page => 1).should == [course]
|
||||
|
@ -110,8 +110,8 @@ describe "BookmarkedCollection" do
|
|||
|
||||
describe ".merge" do
|
||||
before :each do
|
||||
@created_scope = Course.scoped(:conditions => {:workflow_state => 'created'})
|
||||
@deleted_scope = Course.scoped(:conditions => {:workflow_state => 'deleted'})
|
||||
@created_scope = Course.where(:workflow_state => 'created')
|
||||
@deleted_scope = Course.where(:workflow_state => 'deleted')
|
||||
|
||||
Course.delete_all
|
||||
@created_course1 = @created_scope.create!
|
||||
|
@ -206,8 +206,8 @@ describe "BookmarkedCollection" do
|
|||
|
||||
describe ".concat" do
|
||||
before :each do
|
||||
@created_scope = Course.scoped(:conditions => {:workflow_state => 'created'})
|
||||
@deleted_scope = Course.scoped(:conditions => {:workflow_state => 'deleted'})
|
||||
@created_scope = Course.where(:workflow_state => 'created')
|
||||
@deleted_scope = Course.where(:workflow_state => 'deleted')
|
||||
|
||||
Course.delete_all
|
||||
@created_course1 = @created_scope.create!
|
||||
|
@ -263,8 +263,8 @@ describe "BookmarkedCollection" do
|
|||
describe "nested compositions" do
|
||||
before :each do
|
||||
@user_scope = User
|
||||
@created_scope = Course.scoped(:conditions => {:workflow_state => 'created'})
|
||||
@deleted_scope = Course.scoped(:conditions => {:workflow_state => 'deleted'})
|
||||
@created_scope = Course.where(:workflow_state => 'created')
|
||||
@deleted_scope = Course.where(:workflow_state => 'deleted')
|
||||
|
||||
# user's names are so it sorts Created X < Creighton < Deanne < Deleted
|
||||
# X when using NameBookmarks
|
||||
|
|
|
@ -31,9 +31,9 @@ describe "Canvas::TempTable" do
|
|||
@e4 = c2.enroll_student(u1, :enrollment_state => 'active')
|
||||
@e5 = c2.enroll_student(u2, :enrollment_state => 'active')
|
||||
@e6 = c2.enroll_student(u3, :enrollment_state => 'active')
|
||||
@scope = Course.active.scoped(:select => "enrollments.id AS e_id",
|
||||
:joins => :enrollments, :order => "e_id asc")
|
||||
@sql = @scope.construct_finder_sql({})
|
||||
@scope = Course.active.select("enrollments.id AS e_id").
|
||||
joins(:enrollments).order("e_id asc")
|
||||
@sql = @scope.to_sql
|
||||
end
|
||||
|
||||
it "should not create a temp table before executing" do
|
||||
|
|
|
@ -444,7 +444,7 @@ describe "Canvas Cartridge importing" do
|
|||
mod3.add_item({ :title => 'Example 1', :type => 'external_url', :url => 'http://a.example.com/' })
|
||||
mod3.add_item({ :title => 'Example 2', :type => 'external_url', :url => 'http://b.example.com/' })
|
||||
ct = mod3.add_item({ :title => 'Example 3', :type => 'external_url', :url => 'http://b.example.com/with%20space' })
|
||||
ContentTag.update_all({:url => "http://b.example.com/with space"}, "id=#{ct.id}")
|
||||
ContentTag.where(:id => ct).update_all(:url => "http://b.example.com/with space")
|
||||
|
||||
# attachments are migrated with just their filename as display_name,
|
||||
# if a content tag has a different title the display_name should not update
|
||||
|
|
|
@ -147,7 +147,7 @@ shared_examples_for "an object whose dates are overridable" do
|
|||
|
||||
it "returns a scope" do
|
||||
# can't use "should respond_to", because that delegates to the instantiated Array
|
||||
lambda{ overridable.overrides_visible_to(@teacher).scoped({}) }.should_not raise_exception
|
||||
lambda{ overridable.overrides_visible_to(@teacher).scoped }.should_not raise_exception
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ describe IncomingMessageProcessor do
|
|||
|
||||
def check_new_message(bounce_type)
|
||||
Message.count.should == @previous_message_count + 1
|
||||
@new_message = Message.find(:first, :order => 'created_at DESC')
|
||||
@new_message = Message.order("created_at DESC").first
|
||||
@new_message.subject.should match(/Reply Failed/)
|
||||
@new_message.body.should match(case bounce_type
|
||||
when :unknown then /unknown mailbox/
|
||||
|
|
|
@ -32,12 +32,13 @@ describe "MessageableUser" do
|
|||
|
||||
it "should combine common_course_column and common_role_column in common_courses" do
|
||||
course_with_student(:active_all => true)
|
||||
messageable_user = MessageableUser.find(:first,
|
||||
:select => MessageableUser.build_select(
|
||||
messageable_user = MessageableUser.
|
||||
select(MessageableUser.build_select(
|
||||
:common_course_column => "'course_column'",
|
||||
:common_role_column => "'role_column'"),
|
||||
:conditions => {:id => @student.id},
|
||||
:group => MessageableUser.connection.group_by(*MessageableUser::COLUMNS))
|
||||
:common_role_column => "'role_column'")).
|
||||
where(:id => @student).
|
||||
group(MessageableUser.connection.group_by(*MessageableUser::COLUMNS)).
|
||||
first
|
||||
messageable_user.send(:read_attribute, :common_courses).
|
||||
should == "course_column:role_column"
|
||||
end
|
||||
|
@ -45,13 +46,14 @@ describe "MessageableUser" do
|
|||
it "should combine multiple (course,role) pairs in common_courses" do
|
||||
course_with_ta(:active_all => true)
|
||||
multiple_student_enrollment(@ta, @course.course_sections.create!)
|
||||
messageable_user = MessageableUser.find(:first,
|
||||
:select => MessageableUser.build_select(
|
||||
messageable_user = MessageableUser.
|
||||
select(MessageableUser.build_select(
|
||||
:common_course_column => "'course'",
|
||||
:common_role_column => 'enrollments.type'),
|
||||
:joins => 'INNER JOIN enrollments ON enrollments.user_id=users.id',
|
||||
:conditions => {:id => @ta.id},
|
||||
:group => MessageableUser.connection.group_by(*MessageableUser::COLUMNS))
|
||||
:common_role_column => 'enrollments.type')).
|
||||
joins('INNER JOIN enrollments ON enrollments.user_id=users.id').
|
||||
where(:id => @ta.id).
|
||||
group(MessageableUser.connection.group_by(*MessageableUser::COLUMNS)).
|
||||
first
|
||||
messageable_user.send(:read_attribute, :common_courses).split(/,/).sort.
|
||||
should == ["course:StudentEnrollment", "course:TaEnrollment"]
|
||||
end
|
||||
|
@ -59,11 +61,12 @@ describe "MessageableUser" do
|
|||
it "should combine multiple common_group_column values in common_groups" do
|
||||
group1 = group_with_user(:active_all => true).group
|
||||
group2 = group_with_user(:user => @user, :active_all => true).group
|
||||
messageable_user = MessageableUser.find(:first,
|
||||
:select => MessageableUser.build_select(:common_group_column => "group_memberships.group_id"),
|
||||
:joins => 'INNER JOIN group_memberships ON group_memberships.user_id=users.id',
|
||||
:conditions => {:id => @user.id},
|
||||
:group => MessageableUser.connection.group_by(*MessageableUser::COLUMNS))
|
||||
messageable_user = MessageableUser.
|
||||
select(MessageableUser.build_select(:common_group_column => "group_memberships.group_id")).
|
||||
joins('INNER JOIN group_memberships ON group_memberships.user_id=users.id').
|
||||
where(:id => @user).
|
||||
group(MessageableUser.connection.group_by(*MessageableUser::COLUMNS)).
|
||||
first
|
||||
messageable_user.send(:read_attribute, :common_groups).split(/,/).map(&:to_i).sort.
|
||||
should == [group1.id, group2.id].sort
|
||||
end
|
||||
|
|
|
@ -37,8 +37,8 @@ describe ModelCache do
|
|||
end
|
||||
|
||||
user_with_pseudonym(:name => 'qwerty')
|
||||
@user = TestModelCacheUser.find(:first, :conditions => {:id => @user.id})
|
||||
@pseudonym = TestModelCachePseudonym.find(:first, :conditions => {:id => @pseudonym.id})
|
||||
@user = TestModelCacheUser.where(:id => @user).first
|
||||
@pseudonym = TestModelCachePseudonym.where(:id => @pseudonym).first
|
||||
end
|
||||
|
||||
after do
|
||||
|
@ -81,7 +81,7 @@ describe ModelCache do
|
|||
|
||||
it "should not cache any other lookups" do
|
||||
ModelCache.with_cache(:test_model_cache_users => [@user]) do
|
||||
u1 = TestModelCacheUser.find(:first, :conditions => {:id => @user.id})
|
||||
u1 = TestModelCacheUser.where(:id => @user.id).first
|
||||
u1.should eql(@user)
|
||||
u1.should_not equal(@user)
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ describe "PaginatedCollection" do
|
|||
p2.current_page.should == 2
|
||||
p2.next_page.should be_nil
|
||||
p2.previous_page.should == 1
|
||||
p1.should == User.active.all(:order => :id).map(&:id)[0,2]
|
||||
p2.should == User.active.all(:order => :id).map(&:id)[2,1]
|
||||
p1.should == User.active.order(:id).pluck(:id)[0,2]
|
||||
p2.should == User.active.order(:id).pluck(:id)[2,1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -323,7 +323,7 @@ describe SIS::CSV::EnrollmentImporter do
|
|||
"test_1,user_1,student,,deleted,"
|
||||
)
|
||||
@course = Course.find_by_sis_source_id('test_1')
|
||||
scope = Enrollment.scoped(:conditions => { :course_id => @course.id })
|
||||
scope = Enrollment.where(:course_id => @course)
|
||||
scope.count.should == 1
|
||||
@enrollment = scope.first
|
||||
@enrollment.should be_deleted
|
||||
|
|
|
@ -52,7 +52,7 @@ describe SIS::CSV::GroupImporter do
|
|||
"group_id,account_id,name,status",
|
||||
"G001,,Group 1,available",
|
||||
"G002,A002,Group 2,deleted")
|
||||
groups = Group.all(:order => :id)
|
||||
groups = Group.order(:id).all
|
||||
groups.map(&:account_id).should == [@account.id, @sub.id]
|
||||
groups.map(&:sis_source_id).should == %w(G001 G002)
|
||||
groups.map(&:name).should == ["Group 1", "Group 2"]
|
||||
|
@ -64,7 +64,7 @@ describe SIS::CSV::GroupImporter do
|
|||
process_csv_data_cleanly(
|
||||
"group_id,name,status",
|
||||
"G001,Group 1,available")
|
||||
groups = Group.all(:order => :id)
|
||||
groups = Group.order(:id).all
|
||||
groups.map(&:account_id).should == [@account.id]
|
||||
groups.map(&:sis_source_id).should == %w(G001)
|
||||
groups.map(&:name).should == ["Group 1"]
|
||||
|
@ -85,7 +85,7 @@ describe SIS::CSV::GroupImporter do
|
|||
"G001,,Group 1-b,available",
|
||||
"G002,A002,Group 2-b,deleted")
|
||||
# group 1's name won't change because it was manually changed
|
||||
groups = Group.all(:order => :id)
|
||||
groups = Group.order(:id).all
|
||||
groups.map(&:name).should == ["Group 1-1", "Group 2-b"]
|
||||
groups.map(&:root_account).should == [@account, @account]
|
||||
groups.map(&:workflow_state).should == %w(available deleted)
|
||||
|
|
|
@ -54,7 +54,7 @@ describe SIS::CSV::GroupMembershipImporter do
|
|||
"group_id,user_id,status",
|
||||
"G001,U001,accepted",
|
||||
"G001,U003,deleted")
|
||||
ms = GroupMembership.all(:order => :id)
|
||||
ms = GroupMembership.order(:id).all
|
||||
ms.map(&:user_id).should == [@user1.id, @user3.id]
|
||||
ms.map(&:group_id).should == [@group.id, @group.id]
|
||||
ms.map(&:workflow_state).should == %w(accepted deleted)
|
||||
|
@ -63,7 +63,7 @@ describe SIS::CSV::GroupMembershipImporter do
|
|||
"group_id,user_id,status",
|
||||
"G001,U001,deleted",
|
||||
"G001,U003,deleted")
|
||||
ms = GroupMembership.all(:order => :id)
|
||||
ms = GroupMembership.order(:id).all
|
||||
ms.map(&:user_id).should == [@user1.id, @user3.id]
|
||||
ms.map(&:group_id).should == [@group.id, @group.id]
|
||||
ms.map(&:workflow_state).should == %w(deleted deleted)
|
||||
|
|
|
@ -357,7 +357,7 @@ describe SIS::CSV::UserImporter do
|
|||
user2.pseudonyms.count.should == 1
|
||||
user2.pseudonyms.first.communication_channel_id.should_not be_nil
|
||||
|
||||
Message.find(:first, :conditions => { :communication_channel_id => user2.email_channel.id, :notification_id => notification.id }).should_not be_nil
|
||||
Message.where(:communication_channel_id => user2.email_channel, :notification_id => notification).first.should_not be_nil
|
||||
end
|
||||
|
||||
it "should not notify about a merge opportunity to an SIS user in the same account" do
|
||||
|
@ -377,7 +377,7 @@ describe SIS::CSV::UserImporter do
|
|||
user1.pseudonyms.first.communication_channel_id.should_not be_nil
|
||||
user2.pseudonyms.first.communication_channel_id.should_not be_nil
|
||||
|
||||
Message.find(:first, :conditions => { :communication_channel_id => user2.email_channel.id, :notification_id => notification.id }).should be_nil
|
||||
Message.where(:communication_channel_id => user2.email_channel, :notification_id => notification).first.should be_nil
|
||||
end
|
||||
|
||||
it "should not notify about merge opportunities for users that have no means of logging in" do
|
||||
|
@ -397,7 +397,7 @@ describe SIS::CSV::UserImporter do
|
|||
user1.pseudonyms.first.communication_channel_id.should_not be_nil
|
||||
user2.pseudonyms.first.communication_channel_id.should_not be_nil
|
||||
|
||||
Message.find(:first, :conditions => { :communication_channel_id => user2.email_channel.id, :notification_id => notification.id }).should be_nil
|
||||
Message.where(:communication_channel_id => user2.email_channel, :notification_id => notification).first.should be_nil
|
||||
end
|
||||
|
||||
it "should not have problems updating a user to a conflicting email" do
|
||||
|
@ -426,7 +426,7 @@ describe SIS::CSV::UserImporter do
|
|||
user2.email_channel.should be_active
|
||||
user2.email.should == 'user1@example.com'
|
||||
|
||||
Message.find(:first, :conditions => { :communication_channel_id => user2.email_channel.id, :notification_id => notification.id }).should be_nil
|
||||
Message.where(:communication_channel_id => user2.email_channel, :notification_id => notification).first.should be_nil
|
||||
end
|
||||
|
||||
it "should not have a problem adding an existing e-mail that differs in case" do
|
||||
|
@ -490,7 +490,7 @@ describe SIS::CSV::UserImporter do
|
|||
)
|
||||
user2.reload
|
||||
|
||||
Message.find(:first, :conditions => { :communication_channel_id => user2.email_channel.id, :notification_id => notification.id }).should_not be_nil
|
||||
Message.where(:communication_channel_id => user2.email_channel, :notification_id => notification).first.should_not be_nil
|
||||
end
|
||||
|
||||
it "should not send merge opportunity notifications if the conflicting cc is retired or unconfirmed" do
|
||||
|
@ -508,7 +508,7 @@ describe SIS::CSV::UserImporter do
|
|||
user1.communication_channels.length.should == 1
|
||||
user1.email.should == 'user1@example.com'
|
||||
[cc1, cc2].should_not be_include(user1.email_channel)
|
||||
Message.find(:first, :conditions => { :communication_channel_id => user1.email_channel.id, :notification_id => notification.id }).should be_nil
|
||||
Message.where(:communication_channel_id => user1.email_channel, :notification_id => notification).first.should be_nil
|
||||
end
|
||||
|
||||
it "should create everything in the deleted state when deleted initially" do
|
||||
|
|
|
@ -401,7 +401,7 @@ answers:
|
|||
}.force_encoding('binary').strip
|
||||
# now actually insert it into an AR column
|
||||
aq = assessment_question_model
|
||||
AssessmentQuestion.update_all({ :question_data => yaml_blob }, { :id => aq.id })
|
||||
AssessmentQuestion.where(:id => aq).update_all(:question_data => yaml_blob)
|
||||
text = aq.reload.question_data['answers'][0]['valid_ascii']
|
||||
text.should == "text"
|
||||
text.encoding.should == Encoding::UTF_8
|
||||
|
|
|
@ -29,7 +29,7 @@ describe 'DataFixup::FixBulkMessageAttachments' do
|
|||
ConversationBatch.generate(root_message, 20.times.map{ user }, :sync)
|
||||
|
||||
# ensure they aren't linked to the attachment
|
||||
AttachmentAssociation.delete_all(["context_id <> ?", root_message.id])
|
||||
AttachmentAssociation.where("context_id<>?", root_message).delete_all
|
||||
|
||||
DataFixup::FixBulkMessageAttachments.run
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ describe 'FixUserMergeConversations2' do
|
|||
borked_cps = borked.conversation_participants.all
|
||||
borked_cmps = borked_cps.map(&:conversation_message_participants).flatten
|
||||
m1 = borked.add_message(u1, "test")
|
||||
Conversation.delete_all(:id => borked.id) # bypass callbacks
|
||||
Conversation.where(:id => borked).delete_all # bypass callbacks
|
||||
|
||||
correct = Conversation.initiate([u1, u2], true)
|
||||
m2 = correct.add_message(u1, "test2")
|
||||
|
|
|
@ -48,7 +48,7 @@ describe 'DataFixup::RemoveExtraneousConversationTags' do
|
|||
# fake up the bad data
|
||||
@conversation.update_attribute :tags, [@course1.asset_string, @course2.asset_string]
|
||||
@cp1.update_attribute :tags, [@course1.asset_string, @course2.asset_string]
|
||||
cmp1 = @cp1.conversation_message_participants.find(:first, :conditions => ["conversation_message_id = ?", @message.id])
|
||||
cmp1 = @cp1.conversation_message_participants.where(:conversation_message_id => @message).first
|
||||
cmp1.update_attribute :tags, [@course2.asset_string]
|
||||
|
||||
DataFixup::RemoveExtraneousConversationTags.fix_private_conversation!(@conversation)
|
||||
|
@ -61,7 +61,7 @@ describe 'DataFixup::RemoveExtraneousConversationTags' do
|
|||
it "should fix invalid participant tags even if the conversation's tags are correct" do
|
||||
# fake up the bad data
|
||||
@cp1.update_attribute :tags, [@course1.asset_string, @course2.asset_string]
|
||||
cmp1 = @cp1.conversation_message_participants.find(:first, :conditions => ["conversation_message_id = ?", @message.id])
|
||||
cmp1 = @cp1.conversation_message_participants.where(:conversation_message_id => @message).first
|
||||
cmp1.update_attribute :tags, [@course2.asset_string]
|
||||
|
||||
DataFixup::RemoveExtraneousConversationTags.fix_private_conversation!(@conversation)
|
||||
|
|
|
@ -41,7 +41,7 @@ describe 'DataFixup::RemoveMultipleRootFolders' do
|
|||
c.folders.each do |f|
|
||||
f.attachments.delete_all
|
||||
end
|
||||
Folder.delete_all(:id => c.folders.map(&:id))
|
||||
c.folders.scoped.delete_all
|
||||
c.delete
|
||||
end
|
||||
RemoveMultipleRootFolders.up
|
||||
|
@ -56,19 +56,17 @@ describe 'DataFixup::RemoveMultipleRootFolders' do
|
|||
empty_folders << context.folders.create!(:name => "name2")
|
||||
empty_folders << context.folders.create!(:name => "name3")
|
||||
|
||||
Folder.update_all({:parent_folder_id => nil}, {:context_type => context.class.to_s, :context_id => context.id})
|
||||
scope = Folder.where(:context_type => context.class.to_s, :context_id => context)
|
||||
scope.update_all(:parent_folder_id => nil)
|
||||
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
context.class.to_s, context.id, 'deleted']
|
||||
).should == 4
|
||||
scope.where("workflow_state<>'deleted' AND parent_folder_id IS NULL").count.should == 4
|
||||
end
|
||||
|
||||
DataFixup::RemoveMultipleRootFolders.run(:limit => 2)
|
||||
|
||||
@contexts.each do |c|
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c.id, 'deleted']
|
||||
).should == 1
|
||||
Folder.where("context_type=? AND context_id=? AND workflow_state<>'deleted' AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c).count.should == 1
|
||||
end
|
||||
|
||||
empty_folders.each do |folder|
|
||||
|
@ -93,19 +91,17 @@ describe 'DataFixup::RemoveMultipleRootFolders' do
|
|||
a.uploaded_data = default_uploaded_data
|
||||
a.save!
|
||||
|
||||
Folder.update_all({:parent_folder_id => nil}, {:id => [extra_folder1.id, extra_folder2.id]})
|
||||
Folder.where(:id => [extra_folder1, extra_folder2]).update_all(:parent_folder_id => nil)
|
||||
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
context.class.to_s, context.id, 'deleted']
|
||||
).should == 3
|
||||
Folder.where("context_type=? AND context_id=? AND workflow_state<>'deleted' AND parent_folder_id IS NULL",
|
||||
context.class.to_s, context).count.should == 3
|
||||
end
|
||||
|
||||
DataFixup::RemoveMultipleRootFolders.run(:limit => 2)
|
||||
|
||||
@contexts.each do |c|
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c.id, 'deleted']
|
||||
).should == 1
|
||||
Folder.where("context_type=? AND context_id=? AND workflow_state<>'deleted' AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c).count.should == 1
|
||||
end
|
||||
|
||||
extra_folders.each do |folder|
|
||||
|
@ -142,19 +138,17 @@ describe 'DataFixup::RemoveMultipleRootFolders' do
|
|||
a.uploaded_data = default_uploaded_data
|
||||
a.save!
|
||||
|
||||
Folder.update_all({:parent_folder_id => nil}, {:id => [extra_folder1.id, extra_folder2.id]})
|
||||
Folder.where(:id => [extra_folder1, extra_folder2]).update_all(:parent_folder_id => nil)
|
||||
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
context.class.to_s, context.id, 'deleted']
|
||||
).should == 4
|
||||
Folder.where("context_type=? AND context_id=? AND workflow_state<>'deleted' AND parent_folder_id IS NULL",
|
||||
context.class.to_s, context).count.should == 4
|
||||
end
|
||||
|
||||
DataFixup::RemoveMultipleRootFolders.run(:limit => 2)
|
||||
|
||||
@contexts.each do |c|
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c.id, 'deleted']
|
||||
).should == 1
|
||||
Folder.where("context_type=? AND context_id=? AND workflow_state<>'deleted' AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c).count.should == 1
|
||||
end
|
||||
|
||||
extra_folders.each do |folder|
|
||||
|
@ -185,19 +179,17 @@ describe 'DataFixup::RemoveMultipleRootFolders' do
|
|||
context.folders.find_by_name(root_folder_name).delete
|
||||
context.folders.find_by_name(root_folder_name).should be_nil
|
||||
|
||||
Folder.update_all({:parent_folder_id => nil}, {:id => [extra_folder1.id, extra_folder2.id]})
|
||||
Folder.where(:id => [extra_folder1, extra_folder2]).update_all(:parent_folder_id => nil)
|
||||
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
context.class.to_s, context.id, 'deleted']
|
||||
).should == 2
|
||||
Folder.where("context_type=? AND context_id=? AND workflow_state<>'deleted' AND parent_folder_id IS NULL",
|
||||
context.class.to_s, context).count.should == 2
|
||||
end
|
||||
|
||||
DataFixup::RemoveMultipleRootFolders.run(:limit => 2)
|
||||
|
||||
@contexts.each do |c|
|
||||
Folder.count(:conditions => ["context_type = ? AND context_id = ? AND workflow_state != ? AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c.id, 'deleted']
|
||||
).should == 1
|
||||
Folder.where("context_type=? AND context_id=? AND workflow_state<>'deleted' AND parent_folder_id IS NULL",
|
||||
c.class.to_s, c).count.should == 1
|
||||
|
||||
root_folder_name = get_root_folder_name(c)
|
||||
c.folders.find_by_name(root_folder_name).should_not be_nil
|
||||
|
|
|
@ -28,7 +28,7 @@ describe 'SetSamlEntityId' do
|
|||
@account = Account.new
|
||||
@account.save
|
||||
@aac = @account.account_authorization_configs.create!(:auth_type => "saml")
|
||||
AccountAuthorizationConfig.update_all(:entity_id => nil, :id => [@aac.id])
|
||||
AccountAuthorizationConfig.where(:id => @aac).update_all(:entity_id => nil)
|
||||
end
|
||||
|
||||
it "should set the entity_id to the current setting if none is set" do
|
||||
|
|
|
@ -81,7 +81,7 @@ describe ActiveRecord::Base do
|
|||
end
|
||||
|
||||
it "should find each enrollment from course join" do
|
||||
e = Course.active.scoped(:joins => :enrollments)
|
||||
e = Course.active.joins(:enrollments)
|
||||
all_enrollments = []
|
||||
e.useful_find_each(:batch_size => 2) do |e|
|
||||
all_enrollments << e.id
|
||||
|
@ -90,7 +90,7 @@ describe ActiveRecord::Base do
|
|||
end
|
||||
|
||||
it "should find in batches all enrollments from course join" do
|
||||
e = Course.active.scoped(:select => "enrollments.id as eid", :joins => :enrollments)
|
||||
e = Course.active.select("enrollments.id as eid").joins(:enrollments)
|
||||
all_enrollments = []
|
||||
e.useful_find_in_batches(:batch_size => 2) do |batch|
|
||||
batch.each do |e|
|
||||
|
@ -101,8 +101,8 @@ describe ActiveRecord::Base do
|
|||
end
|
||||
|
||||
it "should find each enrollment from course using temp table" do
|
||||
e = Course.active.scoped(:select => "enrollments.id AS e_id",
|
||||
:joins => :enrollments, :order => "e_id asc")
|
||||
e = Course.active.select("enrollments.id AS e_id").
|
||||
joins(:enrollments).order("e_id asc")
|
||||
es = []
|
||||
e.find_each_with_temp_table(:batch_size => 2) do |record|
|
||||
es << record["e_id"]
|
||||
|
@ -113,8 +113,8 @@ describe ActiveRecord::Base do
|
|||
end
|
||||
|
||||
it "should find all enrollments from course join in batches" do
|
||||
e = Course.active.scoped(:select => "enrollments.id AS e_id",
|
||||
:joins => :enrollments, :order => "e_id asc")
|
||||
e = Course.active.select("enrollments.id AS e_id").
|
||||
joins(:enrollments).order("e_id asc")
|
||||
batch_size = 2
|
||||
es = []
|
||||
e.find_in_batches_with_temp_table(:batch_size => batch_size) do |batch|
|
||||
|
@ -480,18 +480,18 @@ describe ActiveRecord::Base do
|
|||
|
||||
it "should fail with improper nested hashes" do
|
||||
lambda {
|
||||
User.find(:first, :conditions => { :name => { :users => { :id => @user.id }}})
|
||||
User.where(:name => { :users => { :id => @user }}).first
|
||||
}.should raise_error(ActiveRecord::StatementInvalid)
|
||||
end
|
||||
|
||||
it "should fail with dot in nested column name" do
|
||||
lambda {
|
||||
User.find(:first, :conditions => { :name => { "users.id" => @user.id }})
|
||||
User.where(:name => { "users.id" => @user }).first
|
||||
}.should raise_error(ActiveRecord::StatementInvalid)
|
||||
end
|
||||
|
||||
it "should not fail with a dot in column name only" do
|
||||
User.find(:first, :conditions => { 'users.id' => @user.id }).should_not be_nil
|
||||
User.where('users.id' => @user).first.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -517,14 +517,14 @@ describe ActiveRecord::Base do
|
|||
end
|
||||
|
||||
it "should do an update all with a join" do
|
||||
Pseudonym.scoped(:joins => :user).active.update_all({:unique_id => 'pa3'}, {:users => {:name => 'a'}})
|
||||
Pseudonym.joins(:user).active.where(:users => {:name => 'a'}).update_all(:unique_id => 'pa3')
|
||||
@p1.reload.unique_id.should == 'pa3'
|
||||
@p1_2.reload.unique_id.should == 'pa2'
|
||||
@p2.reload.unique_id.should == 'pb'
|
||||
end
|
||||
|
||||
it "should do a delete all with a join" do
|
||||
Pseudonym.scoped(:joins => :user).active.delete_all({:users => {:name => 'a'}})
|
||||
Pseudonym.joins(:user).active.where(:users => {:name => 'a'}).delete_all
|
||||
lambda { @p1.reload }.should raise_error(ActiveRecord::RecordNotFound)
|
||||
@u1.reload.should_not be_deleted
|
||||
@p1_2.reload.unique_id.should == 'pa2'
|
||||
|
|
|
@ -129,7 +129,7 @@ describe AssignmentOverride do
|
|||
end
|
||||
|
||||
def invalid_id_for_model(model)
|
||||
(model.scoped(:select => 'max(id) as id').first.id || 0) + 1
|
||||
(model.maximum(:id) || 0) + 1
|
||||
end
|
||||
|
||||
it "should reject non-nil set_id with an adhoc set" do
|
||||
|
|
|
@ -50,7 +50,7 @@ describe Assignment do
|
|||
it "should touch assignment group on create/save" do
|
||||
course
|
||||
group = @course.assignment_groups.create!(:name => "Assignments")
|
||||
AssignmentGroup.update_all({ :updated_at => 1.hour.ago }, { :id => group.id })
|
||||
AssignmentGroup.where(:id => group).update_all(:updated_at => 1.hour.ago)
|
||||
orig_time = group.reload.updated_at.to_i
|
||||
a = @course.assignments.build(
|
||||
"title"=>"test",
|
||||
|
@ -167,7 +167,7 @@ describe Assignment do
|
|||
:enrollment_state => 'active',
|
||||
:section => section3,
|
||||
:allow_multiple_enrollments => true)
|
||||
@user.enrollments.count(:conditions => "workflow_state = 'active'").should eql(3)
|
||||
@user.enrollments.where(:workflow_state => 'active').count.should eql(3)
|
||||
@assignment.reload
|
||||
@assignment.needs_grading_count.should eql(1)
|
||||
|
||||
|
@ -181,21 +181,21 @@ describe Assignment do
|
|||
e.destroy
|
||||
@assignment.reload
|
||||
@assignment.needs_grading_count.should eql(0)
|
||||
@user.enrollments.count(:conditions => "workflow_state = 'active'").should eql(0)
|
||||
@user.enrollments.where(:workflow_state => 'active').count.should eql(0)
|
||||
|
||||
# enroll the user as a teacher, it should have no effect
|
||||
e4 = @course.enroll_teacher(@user)
|
||||
e4.accept
|
||||
@assignment.reload
|
||||
@assignment.needs_grading_count.should eql(0)
|
||||
@user.enrollments.count(:conditions => "workflow_state = 'active'").should eql(1)
|
||||
@user.enrollments.where(:workflow_state => 'active').count.should eql(1)
|
||||
end
|
||||
|
||||
it "updated_at should be set when needs_grading_count changes due to a submission" do
|
||||
setup_assignment_with_homework
|
||||
@assignment.needs_grading_count.should eql(1)
|
||||
old_timestamp = Time.now.utc - 1.minute
|
||||
Assignment.update_all({:updated_at => old_timestamp}, {:id => @assignment.id})
|
||||
Assignment.where(:id => @assignment).update_all(:updated_at => old_timestamp)
|
||||
@assignment.grade_student(@user, :grade => "0")
|
||||
@assignment.reload
|
||||
@assignment.needs_grading_count.should eql(0)
|
||||
|
@ -206,7 +206,7 @@ describe Assignment do
|
|||
setup_assignment_with_homework
|
||||
old_timestamp = Time.now.utc - 1.minute
|
||||
@assignment.needs_grading_count.should eql(1)
|
||||
Assignment.update_all({:updated_at => old_timestamp}, {:id => @assignment.id})
|
||||
Assignment.where(:id => @assignment).update_all(:updated_at => old_timestamp)
|
||||
@course.offer!
|
||||
@course.enrollments.find_by_user_id(@user.id).destroy
|
||||
@assignment.reload
|
||||
|
|
|
@ -219,7 +219,7 @@ describe CommunicationChannel do
|
|||
HostUrl.stubs(:context_host).with(account).returns('someserver.com')
|
||||
HostUrl.stubs(:context_host).with(nil).returns('default')
|
||||
@cc.send_confirmation!(account)
|
||||
message = Message.find(:first, :conditions => { :communication_channel_id => @cc.id, :notification_id => notification.id })
|
||||
message = Message.where(:communication_channel_id => @cc, :notification_id => notification).first
|
||||
message.should_not be_nil
|
||||
message.body.should match /someserver.com/
|
||||
end
|
||||
|
|
|
@ -903,7 +903,7 @@ describe ContentMigration do
|
|||
|
||||
it "should add a warning instead of failing when trying to copy an invalid file" do
|
||||
att = Attachment.create!(:filename => 'dummy.txt', :uploaded_data => StringIO.new('fakety'), :folder => Folder.root_folders(@copy_from).first, :context => @copy_from)
|
||||
Attachment.update_all({:filename => nil}, {:id => att.id})
|
||||
Attachment.where(:id => att).update_all(:filename => nil)
|
||||
|
||||
att.reload
|
||||
att.should_not be_valid
|
||||
|
|
|
@ -56,7 +56,7 @@ describe ContentParticipationCount do
|
|||
it "should not save if not changed" do
|
||||
time = Time.now.utc - 1.day
|
||||
cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => "Submission")
|
||||
ContentParticipationCount.update_all({:updated_at => time}, {:id => cpc.id})
|
||||
ContentParticipationCount.where(:id => cpc).update_all(:updated_at => time)
|
||||
ContentParticipationCount.create_or_update(:context => @course, :user => @student, :content_type => "Submission")
|
||||
cpc.reload.updated_at.to_i.should == time.to_i
|
||||
end
|
||||
|
@ -106,7 +106,7 @@ describe ContentParticipationCount do
|
|||
cpc = ContentParticipationCount.create_or_update(:context => @course, :user => @teacher, :content_type => type)
|
||||
cpc.expects(:refresh_unread_count).never
|
||||
cpc.unread_count.should == 0
|
||||
ContentParticipationCount.update_all({:updated_at => Time.now.utc - 1.day}, {:id => cpc.id})
|
||||
ContentParticipationCount.where(:id => cpc).update_all(:updated_at => Time.now.utc - 1.day)
|
||||
cpc.reload
|
||||
cpc.expects(:refresh_unread_count)
|
||||
cpc.unread_count.should == 0
|
||||
|
|
|
@ -54,7 +54,7 @@ describe ContentParticipation do
|
|||
})
|
||||
}.to change(ContentParticipation, :count).by 0
|
||||
|
||||
cp = ContentParticipation.find(:first, :conditions => { :user_id => @student.id })
|
||||
cp = ContentParticipation.where(:user_id => @student).first
|
||||
cp.workflow_state.should == "unread"
|
||||
end
|
||||
end
|
||||
|
@ -74,7 +74,7 @@ describe ContentParticipation do
|
|||
:user => @student,
|
||||
:workflow_state => "unread",
|
||||
})
|
||||
cpc = ContentParticipationCount.find(:first, :conditions => { :user_id => @student.id })
|
||||
cpc = ContentParticipationCount.where(:user_id => @student).first
|
||||
cpc.unread_count.should == 1
|
||||
end
|
||||
|
||||
|
@ -92,7 +92,7 @@ describe ContentParticipation do
|
|||
:user => @student,
|
||||
:workflow_state => "read",
|
||||
})
|
||||
cpc = ContentParticipationCount.find(:first, :conditions => { :user_id => @student.id })
|
||||
cpc = ContentParticipationCount.where(:user_id => @student).first
|
||||
cpc.unread_count.should == 0
|
||||
end
|
||||
end
|
||||
|
|
|
@ -207,7 +207,7 @@ describe ContentTag do
|
|||
@tag.reload
|
||||
|
||||
yesterday = 1.day.ago
|
||||
ContextModule.update_all({:updated_at => yesterday}, {:id => @module.id})
|
||||
ContextModule.where(:id => @module).update_all(:updated_at => yesterday)
|
||||
|
||||
@tag.skip_touch = true
|
||||
@tag.save
|
||||
|
|
|
@ -753,7 +753,7 @@ describe ContextModule do
|
|||
@old_assignment = @course.assignments.create!(:title => "my assignment")
|
||||
@old_tag = @old_module.add_item({:type => 'assignment', :id => @old_assignment.id})
|
||||
ct = @old_module.add_item({ :title => 'Broken url example', :type => 'external_url', :url => 'http://example.com/with%20space' })
|
||||
ContentTag.update_all({:url => "http://example.com/with space"}, "id=#{ct.id}")
|
||||
ContentTag.where(:id => ct).update_all(:url => "http://example.com/with space")
|
||||
@old_module.reload
|
||||
@old_module.content_tags.length.should eql(2)
|
||||
course_model
|
||||
|
|
|
@ -890,8 +890,8 @@ describe Conversation do
|
|||
source.add_participants(sender, [source_user]) if source_user
|
||||
target.add_participants(sender, [target_user]) if target_user
|
||||
target_user = source_user || target_user
|
||||
message_count = source.shard.activate { ConversationMessageParticipant.count(:all, :joins => :conversation_message, :conditions => {:user_id => target_user.id, :conversation_messages => {:conversation_id => source.id}}) }
|
||||
message_count += target.shard.activate { ConversationMessageParticipant.count(:all, :joins => :conversation_message, :conditions => {:user_id => target_user.id, :conversation_messages => {:conversation_id => target.id}}) }
|
||||
message_count = source.shard.activate { ConversationMessageParticipant.joins(:conversation_message).where(:user_id => target_user, :conversation_messages => {:conversation_id => source}).count }
|
||||
message_count += target.shard.activate { ConversationMessageParticipant.joins(:conversation_message).where(:user_id => target_user, :conversation_messages => {:conversation_id => target}).count }
|
||||
|
||||
source.merge_into(target)
|
||||
|
||||
|
|
|
@ -589,8 +589,8 @@ describe Course, "enroll" do
|
|||
it "should scope correctly when including teachers from course" do
|
||||
account = @course.account
|
||||
@course.enroll_student(@user)
|
||||
scope = account.associated_courses.active.scoped(:select=>"id, name", :joins=>:teachers, :include=>:teachers, :conditions => "enrollments.workflow_state = 'active'")
|
||||
sql = scope.construct_finder_sql({})
|
||||
scope = account.associated_courses.active.select([:id, :name]).joins(:teachers).includes(:teachers).where(:enrollments => { :workflow_state => 'active' })
|
||||
sql = scope.to_sql
|
||||
sql.should match(/enrollments.type = 'TeacherEnrollment'/)
|
||||
end
|
||||
end
|
||||
|
@ -2587,7 +2587,7 @@ describe Course, "inherited_assessment_question_banks" do
|
|||
bank = @course.assessment_question_banks.create
|
||||
|
||||
banks = @course.inherited_assessment_question_banks(true)
|
||||
banks.scoped(:order => :id).should eql [root_bank, account_bank, bank]
|
||||
banks.order(:id).should eql [root_bank, account_bank, bank]
|
||||
banks.find_by_id(bank.id).should eql bank
|
||||
banks.find_by_id(account_bank.id).should eql account_bank
|
||||
banks.find_by_id(root_bank.id).should eql root_bank
|
||||
|
@ -2618,7 +2618,7 @@ describe Course, "section_visibility" do
|
|||
|
||||
it "should return a scope from sections_visible_to" do
|
||||
# can't use "should respond_to", because that delegates to the instantiated Array
|
||||
lambda{ @course.sections_visible_to(@teacher).scoped({}) }.should_not raise_exception
|
||||
lambda{ @course.sections_visible_to(@teacher).scoped }.should_not raise_exception
|
||||
end
|
||||
|
||||
context "full" do
|
||||
|
@ -2977,7 +2977,7 @@ describe Course do
|
|||
|
||||
it "should generate a code on demand for existing self enrollment courses" do
|
||||
c1 = course()
|
||||
Course.update_all({:self_enrollment => true}, {:id => @course.id})
|
||||
Course.where(:id => @course).update_all(:self_enrollment => true)
|
||||
c1.reload
|
||||
c1.read_attribute(:self_enrollment_code).should be_nil
|
||||
c1.self_enrollment_code.should_not be_nil
|
||||
|
@ -3026,7 +3026,7 @@ describe Course do
|
|||
|
||||
it "should return a scope" do
|
||||
# can't use "should respond_to", because that delegates to the instantiated Array
|
||||
lambda{ @course.groups_visible_to(@user).scoped({}) }.should_not raise_exception
|
||||
lambda{ @course.groups_visible_to(@user).scoped }.should_not raise_exception
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3164,7 +3164,7 @@ describe Course do
|
|||
end
|
||||
|
||||
it "should play nice with other scopes" do
|
||||
Course.with_enrollments.scoped(:conditions => {:name => 'A'}).should == [@course1a]
|
||||
Course.with_enrollments.where(:name => 'A').should == [@course1a]
|
||||
end
|
||||
|
||||
it "should be disjoint with #without_enrollments" do
|
||||
|
@ -3178,7 +3178,7 @@ describe Course do
|
|||
end
|
||||
|
||||
it "should play nice with other scopes" do
|
||||
Course.without_enrollments.scoped(:conditions => {:name => 'A'}).should == [@course2a]
|
||||
Course.without_enrollments.where(:name => 'A').should == [@course2a]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3205,7 +3205,7 @@ describe Course do
|
|||
end
|
||||
|
||||
it "should play nice with other scopes" do
|
||||
Course.completed.scoped(:conditions => {:conclude_at => nil}).should == [@c4]
|
||||
Course.completed.where(:conclude_at => nil).should == [@c4]
|
||||
end
|
||||
|
||||
it "should be disjoint with #not_completed" do
|
||||
|
@ -3219,7 +3219,7 @@ describe Course do
|
|||
end
|
||||
|
||||
it "should play nice with other scopes" do
|
||||
Course.not_completed.scoped(:conditions => {:conclude_at => nil}).should == [@c1]
|
||||
Course.not_completed.where(:conclude_at => nil).should == [@c1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -231,7 +231,7 @@ describe DiscussionEntry do
|
|||
@subtopic.root_topic = @topic
|
||||
@subtopic.save!
|
||||
|
||||
DiscussionTopic.update_all({ :updated_at => 1.hour.ago }, { :id => [@topic.id, @subtopic.id] })
|
||||
DiscussionTopic.where(:id => [@topic, @subtopic]).update_all(:updated_at => 1.hour.ago)
|
||||
@topic_updated_at = @topic.reload.updated_at
|
||||
@subtopic_updated_at = @subtopic.reload.updated_at
|
||||
|
||||
|
|
|
@ -521,7 +521,7 @@ describe DiscussionTopic do
|
|||
@entry1 = @topic.discussion_entries.create!(:message => "second message", :user => @user)
|
||||
@entry1.created_at = 1.week.ago
|
||||
@entry1.save!
|
||||
@submission = @assignment.submissions.scoped(:conditions => {:user_id => @entry1.user_id}).first
|
||||
@submission = @assignment.submissions.where(:user_id => @entry1.user_id).first
|
||||
end
|
||||
|
||||
it "should not re-flag graded discussion as needs grading if student make another comment" do
|
||||
|
@ -655,7 +655,7 @@ describe DiscussionTopic do
|
|||
@student.reload
|
||||
|
||||
@assignment.grade_student(@student, :grade => 1)
|
||||
@submission = Submission.find(:first, :conditions => {:user_id => @student.id, :assignment_id => @assignment.id})
|
||||
@submission = Submission.where(:user_id => @student, :assignment_id => @assignment).first
|
||||
@submission.workflow_state.should == 'graded'
|
||||
|
||||
@topic.ensure_submission(@student)
|
||||
|
|
|
@ -1181,7 +1181,7 @@ describe Enrollment do
|
|||
it "should uncache user enrollments when rejected" do
|
||||
enable_cache do
|
||||
course_with_student(:active_course => 1)
|
||||
User.update_all({:updated_at => 1.year.ago}, :id => @user.id)
|
||||
User.where(:id => @user).update_all(:updated_at => 1.year.ago)
|
||||
@user.reload
|
||||
@user.cached_current_enrollments.should == [@enrollment]
|
||||
@enrollment.reject!
|
||||
|
@ -1493,7 +1493,7 @@ describe Enrollment do
|
|||
it "should remove the enrollment from User#cached_current_enrollments" do
|
||||
enable_cache do
|
||||
course_with_student(:active_all => 1)
|
||||
User.update_all({:updated_at => 1.day.ago}, :id => @user.id)
|
||||
User.where(:id => @user).update_all(:updated_at => 1.day.ago)
|
||||
@user.reload
|
||||
@user.cached_current_enrollments.should == [ @enrollment ]
|
||||
@enrollment.conclude
|
||||
|
|
|
@ -42,7 +42,7 @@ describe GroupMembership do
|
|||
gm2.reload.should be_deleted
|
||||
|
||||
# should work even if we start with bad data (two accepted memberships)
|
||||
GroupMembership.update_all({:workflow_state => "accepted"}, {:id => gm2.id})
|
||||
GroupMembership.where(:id => gm2).update_all(:workflow_state => "accepted")
|
||||
gm1.save!
|
||||
gm1.reload.should be_accepted
|
||||
gm2.reload.should be_deleted
|
||||
|
@ -229,23 +229,23 @@ describe GroupMembership do
|
|||
|
||||
it "should auto-follow the group when joining the group" do
|
||||
@group.add_user(@user, 'accepted')
|
||||
@user.reload.user_follows.find(:first, :conditions => { :followed_item_id => @group.id, :followed_item_type => 'Group' }).should_not be_nil
|
||||
@user.reload.user_follows.where(:followed_item_id => @group, :followed_item_type => 'Group').first.should_not be_nil
|
||||
end
|
||||
|
||||
it "should auto-follow the group when a request is accepted" do
|
||||
@membership = @group.add_user(@user, 'requested')
|
||||
@user.reload.user_follows.find(:first, :conditions => { :followed_item_id => @group.id, :followed_item_type => 'Group' }).should be_nil
|
||||
@user.reload.user_follows.where(:followed_item_id => @group, :followed_item_type => 'Group').first.should be_nil
|
||||
@membership.workflow_state = 'accepted'
|
||||
@membership.save!
|
||||
@user.reload.user_follows.find(:first, :conditions => { :followed_item_id => @group.id, :followed_item_type => 'Group' }).should_not be_nil
|
||||
@user.reload.user_follows.where(:followed_item_id => @group, :followed_item_type => 'Group').first.should_not be_nil
|
||||
end
|
||||
|
||||
it "should auto-follow the group when an invitation is accepted" do
|
||||
@membership = @group.add_user(@user, 'invited')
|
||||
@user.reload.user_follows.find(:first, :conditions => { :followed_item_id => @group.id, :followed_item_type => 'Group' }).should be_nil
|
||||
@user.reload.user_follows.where(:followed_item_id => @group, :followed_item_type => 'Group').first.should be_nil
|
||||
@membership.workflow_state = 'accepted'
|
||||
@membership.save!
|
||||
@user.reload.user_follows.find(:first, :conditions => { :followed_item_id => @group.id, :followed_item_type => 'Group' }).should_not be_nil
|
||||
@user.reload.user_follows.where(:followed_item_id => @group, :followed_item_type => 'Group').first.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ describe Group do
|
|||
}.each do |join_level, workflow_state|
|
||||
group = group_model(:join_level => join_level, :group_category => @communities)
|
||||
group.add_user(@user)
|
||||
group.group_memberships.scoped(:conditions => { :workflow_state => workflow_state, :user_id => @user.id }).first.should_not be_nil
|
||||
group.group_memberships.where(:workflow_state => workflow_state, :user_id => @user).first.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -150,7 +150,7 @@ describe Group do
|
|||
|
||||
[ 'invited', 'requested', 'accepted' ].each do |workflow_state|
|
||||
@group.add_user(@user, workflow_state)
|
||||
@group.group_memberships.scoped(:conditions => { :workflow_state => workflow_state, :user_id => @user.id }).first.should_not be_nil
|
||||
@group.group_memberships.where(:workflow_state => workflow_state, :user_id => @user).first.should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -325,7 +325,7 @@ describe Group do
|
|||
@group.add_user(@user3, 'invited')
|
||||
@group.add_user(@user4, 'requested')
|
||||
@group.add_user(@user5, 'rejected')
|
||||
GroupMembership.update_all({:moderator => true}, {:group_id => @group.id, :user_id => @user2.id})
|
||||
GroupMembership.where(:group_id => @group, :user_id => @user2).update_all(:moderator => true)
|
||||
|
||||
@group.has_member?(@user1).should be_true
|
||||
@group.has_member?(@user2).should be_true
|
||||
|
@ -348,7 +348,7 @@ describe Group do
|
|||
@group.add_user(@user3, 'invited')
|
||||
@group.add_user(@user4, 'requested')
|
||||
@group.add_user(@user5, 'rejected')
|
||||
GroupMembership.update_all({:moderator => true}, {:group_id => @group.id, :user_id => [@user2.id, @user3.id, @user4.id, @user5.id]})
|
||||
GroupMembership.where(:group_id => @group, :user_id => [@user2, @user3, @user4, @user5]).update_all(:moderator => true)
|
||||
|
||||
@group.has_moderator?(@user1).should be_false
|
||||
@group.has_moderator?(@user2).should be_true
|
||||
|
|
|
@ -72,7 +72,7 @@ describe NotificationPolicy do
|
|||
@assignment.unpublish!
|
||||
@cc = @student.communication_channels.create(:path => "secondary@example.com")
|
||||
@cc.confirm!
|
||||
NotificationPolicy.delete_all(:notification_id => @notif.id, :communication_channel_id => @cc.id)
|
||||
NotificationPolicy.where(:notification_id => @notif, :communication_channel_id => @cc).delete_all
|
||||
@assignment.previously_published = false
|
||||
@assignment.save
|
||||
@assignment.publish!
|
||||
|
@ -315,7 +315,7 @@ def policy_setup
|
|||
@student = factory_with_protected_attributes(User, :name => "student", :workflow_state => "registered")
|
||||
e = @course.enroll_student(@student)
|
||||
e.accept!
|
||||
Notification.find(:all).each{|n| n.destroy }
|
||||
Notification.all.each{|n| n.destroy }
|
||||
@notif = Notification.create!(:name => "Assignment Graded", :subject => "Test", :category => 'TestNever')
|
||||
end
|
||||
|
||||
|
|
|
@ -77,7 +77,8 @@ describe Notification do
|
|||
end
|
||||
|
||||
it "should look up all notifications once and cache them thereafter" do
|
||||
Notification.expects(:all).once.returns{ Notification.find(:all) }
|
||||
notifications = Notification.all
|
||||
Notification.expects(:all).once.returns { notifications }
|
||||
Notification.by_name("foo").should eql(Notification.find_by_name("foo"))
|
||||
Notification.by_name("bar").should eql(Notification.find_by_name("bar"))
|
||||
end
|
||||
|
|
|
@ -298,7 +298,7 @@ describe Quiz do
|
|||
|
||||
qq1 = q.quiz_questions.create!(:question_data => { :name => "test 1" }, :quiz_group => g)
|
||||
# make sure we handle sorting with nil positions
|
||||
QuizQuestion.update_all({:position => nil}, {:id => qq1.id})
|
||||
QuizQuestion.where(:id => qq1).update_all(:position => nil)
|
||||
|
||||
q.quiz_questions.create!(:question_data => { :name => "test 2" }, :quiz_group => g)
|
||||
q.quiz_questions.create!(:question_data => { :name => "test 3" })
|
||||
|
|
|
@ -26,11 +26,11 @@ describe QuizSubmission do
|
|||
end
|
||||
|
||||
it "should copy the quiz's points_possible whenever it's saved" do
|
||||
Quiz.update_all("points_possible = 1.1", "id = #{@quiz.id}")
|
||||
Quiz.where(:id => @quiz).update_all(:points_possible => 1.1)
|
||||
q = @quiz.quiz_submissions.create!
|
||||
q.reload.quiz_points_possible.should eql 1.1
|
||||
|
||||
Quiz.update_all("points_possible = 1.9", "id = #{@quiz.id}")
|
||||
Quiz.where(:id => @quiz).update_all(:points_possible => 1.9)
|
||||
q.reload.quiz_points_possible.should eql 1.1
|
||||
|
||||
q.save!
|
||||
|
|
|
@ -47,7 +47,7 @@ describe StreamItem do
|
|||
it "should have a default ttl" do
|
||||
si1 = StreamItem.create! { |si| si.asset_type = 'Message'; si.data = {} }
|
||||
si2 = StreamItem.create! { |si| si.asset_type = 'Message'; si.data = {} }
|
||||
StreamItem.update_all({:updated_at => 1.year.ago}, {:id => si2.id})
|
||||
StreamItem.where(:id => si2).update_all(:updated_at => 1.year.ago)
|
||||
expect {
|
||||
StreamItem.destroy_stream_items_using_setting
|
||||
}.to change(StreamItem, :count).by(-1)
|
||||
|
|
|
@ -121,7 +121,7 @@ describe Submission do
|
|||
@entry1 = @topic.discussion_entries.create(:message => "first entry", :user => @user)
|
||||
@topic.assignment_id = @assignment.id
|
||||
@topic.save!
|
||||
@submission = @assignment.submissions.scoped(:conditions => {:user_id => @entry1.user_id}).first
|
||||
@submission = @assignment.submissions.where(:user_id => @entry1.user_id).first
|
||||
new_time = Time.now + 30.minutes
|
||||
Time.stubs(:now).returns(new_time)
|
||||
@entry2 = @topic.discussion_entries.create(:message => "second entry", :user => @user)
|
||||
|
@ -284,8 +284,8 @@ describe Submission do
|
|||
}.should change StreamItemInstance, :count
|
||||
|
||||
@assignment.unmute!
|
||||
stream_item_ids = StreamItem.all(:select => :id, :conditions => { :asset_type => 'Submission', :asset_id => @assignment.submissions.map(&:id)})
|
||||
stream_item_instances = StreamItemInstance.all(:conditions => { :stream_item_id => stream_item_ids })
|
||||
stream_item_ids = StreamItem.where(:asset_type => 'Submission', :asset_id => @assignment.submissions.all).pluck(:id)
|
||||
stream_item_instances = StreamItemInstance.where(:stream_item_id => stream_item_ids)
|
||||
stream_item_instances.each { |sii| sii.should_not be_hidden }
|
||||
end
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ describe "UserFollow" do
|
|||
it "should delete on the other shard on un-follow" do
|
||||
@uf = @user1.user_follows.create!(:followed_item => @collection)
|
||||
@uf.shard.should == Shard.default
|
||||
@uf2 = @collection.shard.activate { UserFollow.first(:conditions => { :following_user_id => @user1.id, :followed_item_id => @collection.id }) }
|
||||
@uf2 = @collection.shard.activate { UserFollow.where(:following_user_id => @user1, :followed_item_id => @collection).first }
|
||||
@uf2.shard.should == @collection.shard
|
||||
@uf.destroy
|
||||
expect { @collection.shard.activate { @uf2.reload } }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
|
@ -62,7 +62,7 @@ describe "UserFollow" do
|
|||
it "should delete from the other shard to the current" do
|
||||
@uf = @user1.user_follows.create!(:followed_item => @collection)
|
||||
@uf.shard.should == Shard.default
|
||||
@uf2 = @collection.shard.activate { UserFollow.first(:conditions => { :following_user_id => @user1.id, :followed_item_id => @collection.id }) }
|
||||
@uf2 = @collection.shard.activate { UserFollow.where(:following_user_id => @user1, :followed_item_id => @collection).first }
|
||||
@uf2.shard.should == @collection.shard
|
||||
@uf2.destroy
|
||||
expect { @uf.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
|
|
|
@ -737,7 +737,7 @@ describe User do
|
|||
set_up_course_with_users
|
||||
enrollment = @course.enroll_user(@student, 'StudentEnrollment', :enrollment_state => 'active', :limit_privileges_to_course_section => true)
|
||||
# we currently force limit_privileges_to_course_section to be false for students; override it in the db
|
||||
Enrollment.update_all({ :limit_privileges_to_course_section => true }, :id => enrollment.id)
|
||||
Enrollment.where(:id => enrollment).update_all(:limit_privileges_to_course_section => true)
|
||||
messageable_users = search_messageable_users(@student).map(&:id)
|
||||
messageable_users.should include @this_section_user.id
|
||||
messageable_users.should_not include @other_section_user.id
|
||||
|
@ -816,7 +816,7 @@ describe User do
|
|||
set_up_course_with_users
|
||||
enrollment = @course.enroll_user(@student, 'StudentEnrollment', :enrollment_state => 'active', :limit_privileges_to_course_section => true)
|
||||
# we currently force limit_privileges_to_course_section to be false for students; override it in the db
|
||||
Enrollment.update_all({ :limit_privileges_to_course_section => true }, :id => enrollment.id)
|
||||
Enrollment.where(:id => enrollment).update_all(:limit_privileges_to_course_section => true)
|
||||
|
||||
@group.users << @other_section_user
|
||||
|
||||
|
@ -974,7 +974,7 @@ describe User do
|
|||
set_up_course_with_users
|
||||
enrollment = @course.enroll_user(@student, 'StudentEnrollment', :enrollment_state => 'active', :limit_privileges_to_course_section => true)
|
||||
# we currently force limit_privileges_to_course_section to be false for students; override it in the db
|
||||
Enrollment.update_all({ :limit_privileges_to_course_section => true }, :id => enrollment.id)
|
||||
Enrollment.where(:id => enrollment).update_all(:limit_privileges_to_course_section => true)
|
||||
|
||||
@group.users << @other_section_user
|
||||
@this_section_user_enrollment.conclude
|
||||
|
|
|
@ -114,7 +114,7 @@ describe WebConference do
|
|||
# second one doesn't trigger another create call
|
||||
conference.craft_url(@user).should match(/\Ahttp:\/\/bbb\.instructure\.com\/bigbluebutton\/api\/join/)
|
||||
|
||||
WebConference.update_all({:updated_at => 1.day.ago}, {:id => conference.id})
|
||||
WebConference.where(:id => conference).update_all(:updated_at => 1.day.ago)
|
||||
conference.reload
|
||||
|
||||
conference.craft_url(@user).should match(/\Ahttp:\/\/bbb\.instructure\.com\/bigbluebutton\/api\/join/)
|
||||
|
|
|
@ -183,7 +183,7 @@ describe "account admin question bank" do
|
|||
def move_questions_validation(bank_name, questions)
|
||||
new_question_bank = AssessmentQuestionBank.find_by_title(bank_name)
|
||||
new_question_bank.should be_present
|
||||
new_questions = AssessmentQuestion.all(:conditions => {:assessment_question_bank_id => new_question_bank.id})
|
||||
new_questions = AssessmentQuestion.where(:assessment_question_bank_id => new_question_bank).all
|
||||
new_questions.should be_present
|
||||
new_questions.should == questions
|
||||
end
|
||||
|
|
|
@ -214,7 +214,7 @@ describe "site admin jobs ui" do
|
|||
|
||||
context "running jobs" do
|
||||
it "should display running jobs in the workers grid" do
|
||||
j = Delayed::Job.first(:order => :id)
|
||||
j = Delayed::Job.order(:id).first
|
||||
j.lock_exclusively!('my test worker')
|
||||
load_jobs_page
|
||||
ffj('#running-grid .slick-row').size.should == 1
|
||||
|
|
|
@ -206,7 +206,7 @@ describe "assignments" do
|
|||
|
||||
get "/courses/#{@course.id}/assignments"
|
||||
group = @course.assignment_groups.first
|
||||
AssignmentGroup.update_all({:updated_at => 1.hour.ago}, {:id => group.id})
|
||||
AssignmentGroup.where(:id => group).update_all(:updated_at => 1.hour.ago)
|
||||
first_stamp = group.reload.updated_at.to_i
|
||||
f('.add_assignment_link').click
|
||||
wait_for_ajaximations
|
||||
|
@ -388,7 +388,7 @@ describe "assignments" do
|
|||
|
||||
get "/courses/#{@course.id}/assignments"
|
||||
group = @course.assignment_groups.first
|
||||
AssignmentGroup.update_all({:updated_at => 1.hour.ago}, {:id => group.id})
|
||||
AssignmentGroup.where(:id => group).update_all(:updated_at => 1.hour.ago)
|
||||
first_stamp = group.reload.updated_at.to_i
|
||||
f('.add_assignment_link').click
|
||||
wait_for_ajaximations
|
||||
|
|
|
@ -109,7 +109,7 @@ describe "collaborations" do
|
|||
end
|
||||
|
||||
f('.collaboration .title').text.should == new_title
|
||||
Collaboration.last(:order => 'id DESC').title.should == new_title
|
||||
Collaboration.order("id DESC").last.title.should == new_title
|
||||
end
|
||||
|
||||
it 'should be delete-able' do
|
||||
|
@ -126,7 +126,7 @@ describe "collaborations" do
|
|||
wait_for_ajaximations
|
||||
|
||||
f('#no_collaborations_message').should be_displayed
|
||||
Collaboration.last(:order => 'id DESC').should be_deleted
|
||||
Collaboration.order("id DESC").last.should be_deleted
|
||||
end
|
||||
|
||||
it 'should not display the new collaboration form if other collaborations exist' do
|
||||
|
|
|
@ -13,7 +13,6 @@ describe "content exports" do
|
|||
get "/courses/#{@course.id}/content_exports"
|
||||
yield if block_given?
|
||||
submit_form('#exporter_form')
|
||||
Delayed::Job.last(:conditions => {:tag => 'ContentExport#export_course_without_send_later'})
|
||||
@export = keep_trying_until { ContentExport.last }
|
||||
@export.export_course_without_send_later
|
||||
new_download_link = keep_trying_until { f("#export_files a") }
|
||||
|
|
|
@ -10,7 +10,7 @@ shared_examples_for "conversations attachments selenium tests" do
|
|||
|
||||
new_conversation
|
||||
submit_message_form(:attachments => [fullpath])
|
||||
@user.all_conversations.scoped(:order => "conversation_id DESC").last.has_attachments.should be_true
|
||||
@user.all_conversations.order("conversation_id DESC").last.has_attachments.should be_true
|
||||
@user.conversation_attachments_folder.attachments.count.should == 1
|
||||
end
|
||||
|
||||
|
@ -27,7 +27,7 @@ shared_examples_for "conversations attachments selenium tests" do
|
|||
ffj(".attachment_list > .attachment:visible").size.should == 1
|
||||
ffj(".attachment_list > .attachment:visible .remove_link")[0].click
|
||||
submit_message_form
|
||||
@user.all_conversations.scoped(:order => "conversation_id DESC").last.has_attachments.should be_false
|
||||
@user.all_conversations.order("conversation_id DESC").last.has_attachments.should be_false
|
||||
end
|
||||
|
||||
it "should save just one attachment when sending a bulk private message" do
|
||||
|
|
|
@ -205,7 +205,7 @@ describe "dashboard" do
|
|||
|
||||
it "should display student groups in course menu" do
|
||||
@course.update_attributes(:start_at => 2.days.from_now, :conclude_at => 4.days.from_now, :restrict_enrollments_to_course_dates => false)
|
||||
Enrollment.update_all(["created_at = ?", 1.minute.ago])
|
||||
Enrollment.update_all(:created_at => 1.minute.ago)
|
||||
|
||||
get "/"
|
||||
|
||||
|
@ -221,7 +221,7 @@ describe "dashboard" do
|
|||
group = Group.create!(:name => "group1", :context => @course)
|
||||
group.add_user(@user)
|
||||
@course.update_attributes(:start_at => 2.days.from_now, :conclude_at => 4.days.from_now, :restrict_enrollments_to_course_dates => false)
|
||||
Enrollment.update_all(["created_at = ?", 1.minute.ago])
|
||||
Enrollment.update_all(:created_at => 1.minute.ago)
|
||||
|
||||
get "/"
|
||||
|
||||
|
@ -297,7 +297,7 @@ describe "dashboard" do
|
|||
@enrollment.workflow_state = 'active'
|
||||
@enrollment.save!
|
||||
@second_course.reload
|
||||
Enrollment.update_all(["created_at = ?", 1.minute.ago]) # need to make created_at and updated_at different
|
||||
Enrollment.update_all(:created_at => 1.minute.ago) # need to make created_at and updated_at different
|
||||
|
||||
get "/"
|
||||
f('.no-recent-messages').should be_nil
|
||||
|
|
|
@ -52,13 +52,13 @@ def unzip_from_form_to_folder()
|
|||
f('input#zip_file').send_keys(path)
|
||||
submit_form('#zip_file_import_form')
|
||||
|
||||
zfi = keep_trying_until { ZipFileImport.last(:order => :id) }
|
||||
zfi = keep_trying_until { ZipFileImport.order(:id).last }
|
||||
zfi.context.should == @context
|
||||
zfi.folder.should == @folder
|
||||
|
||||
f('.ui-dialog-title').should include_text('Uploading, Please Wait.') # verify it's visible
|
||||
|
||||
job = Delayed::Job.last(:order => :id)
|
||||
job = Delayed::Job.order(:id).last
|
||||
job.tag.should == 'ZipFileImport#process_without_send_later'
|
||||
run_job(job)
|
||||
upload_file(true) if refresh != true && f("#flash_message_holder .ui-state-error").present?
|
||||
|
@ -100,13 +100,13 @@ def unzip_from_form_to_folder()
|
|||
confirm_dialog.accept
|
||||
wait_for_ajax_requests
|
||||
|
||||
zfi = keep_trying_until { ZipFileImport.last(:order => :id) }
|
||||
zfi = keep_trying_until { ZipFileImport.order(:id).last }
|
||||
zfi.context.should == @context
|
||||
zfi.folder.should == folder
|
||||
|
||||
f('.ui-dialog-title').should include_text('Extracting Files into Folder') # verify it's visible
|
||||
|
||||
job = Delayed::Job.last(:order => :id)
|
||||
job = Delayed::Job.order(:id).last
|
||||
job.tag.should == 'ZipFileImport#process_without_send_later'
|
||||
run_job(job)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ def add_user (opts={})
|
|||
f("#pseudonym_unique_id").send_keys email
|
||||
submit_form("#add_user_form")
|
||||
wait_for_ajax_requests
|
||||
user = User.first(:conditions => {:name => name})
|
||||
user = User.where(:name => name).first
|
||||
user.should be_present
|
||||
user.sortable_name.should == sortable_name
|
||||
user.short_name.should == short_name
|
||||
|
|
|
@ -99,7 +99,7 @@ describe "course rubrics" do
|
|||
ff('tr.learning_outcome_criterion td.rating .points').map(&:text).should == @outcome.data[:rubric_criterion][:ratings].map { |c| c[:points].to_s }
|
||||
submit_form('#edit_rubric_form')
|
||||
wait_for_ajaximations
|
||||
rubric = Rubric.last(:order => :id)
|
||||
rubric = Rubric.order(:id).last
|
||||
rubric.data.first[:ratings].map { |r| r[:description] }.should == @outcome.data[:rubric_criterion][:ratings].map { |c| c[:description] }
|
||||
rubric.data.first[:ratings].map { |r| r[:points] }.should == @outcome.data[:rubric_criterion][:ratings].map { |c| c[:points] }
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ eolist
|
|||
unique_ids = ["user1@example.com", "bob@thesagatfamily.name", "A124123"]
|
||||
browser_text = ["user1@example.com\nuser1@example.com\nuser1@example.com", "sagat, bob\nbob sagat\nbob@thesagatfamily.name", "user, login_name\nlogin_name user\nA124123"] if include_short_name
|
||||
browser_text = ["user1@example.com\nuser1@example.com", "sagat, bob\nbob@thesagatfamily.name", "user, login_name\nA124123"] unless include_short_name
|
||||
enrollments = Enrollment.all(:conditions => ["(workflow_state = 'invited' OR workflow_state = 'creation_pending') AND type = ? ", enrollment_type])
|
||||
enrollments = Enrollment.where("(workflow_state='invited' OR workflow_state='creation_pending') AND type=?", enrollment_type).all
|
||||
(enrollments.count > 2).should be_true
|
||||
unique_ids.each do |id|
|
||||
enrollment = find_enrollment_by_id(enrollments, id)
|
||||
|
|
Loading…
Reference in New Issue