spec: fix NameError Api::V1::CustomGradebookColumnDatum

test plan:
- spec pass and the NameError is no longer present in the logs

Change-Id: Icff3377faada8c01d74451e4c100c05e5a6aa7bb
Reviewed-on: https://gerrit.instructure.com/160550
Reviewed-by: Keith T. Garner <kgarner@instructure.com>
Product-Review: Derek Bender <djbender@instructure.com>
QA-Review: Derek Bender <djbender@instructure.com>
Tested-by: Jenkins
This commit is contained in:
Derek Bender 2018-08-13 09:24:40 -05:00
parent 0492a553fb
commit 4588eb1f69
1 changed files with 20 additions and 30 deletions

View File

@ -15,10 +15,10 @@
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
require_relative '../../../spec_helper'
require_relative '../spec_helper'
describe Api::V1::CustomGradebookColumnDatum do
describe "custom_gradebook_column_bulk_upload" do
describe CustomGradebookColumnDatum do
describe "process_bulk_update_custom_columns" do
before :once do
course_with_teacher(active_all: true)
@first_student = student_in_course(active_all: true, course: @course).user
@ -51,26 +51,30 @@ describe Api::V1::CustomGradebookColumnDatum do
end
it "adds a datum for a matching student and column" do
data = @course.custom_gradebook_columns.find_by!(id: @first_col.id).
custom_gradebook_column_data.where(user_id: @first_student.id)
expect(data.count).to eql 1
data = @course.custom_gradebook_columns.
find_by!(id: @first_col.id).
custom_gradebook_column_data.
where(user_id: @first_student.id)
expect(data.count).to be 1
end
it "checks content exists for the first student in the first column" do
data = @course.custom_gradebook_columns.find_by!(id: @first_col.id).
custom_gradebook_column_data.find_by!(user_id: @first_student.id).content
data = @course.custom_gradebook_columns.
find_by!(id: @first_col.id).
custom_gradebook_column_data.
find_by!(user_id: @first_student.id).
content
expect(data).to eql "first column, first student"
end
it "adds data for multiple students for a column" do
data = @course.custom_gradebook_columns.find_by!(id: @first_col.id).
custom_gradebook_column_data
expect(data.count).to eql 2
data = @course.custom_gradebook_columns.find_by!(id: @first_col.id).custom_gradebook_column_data
expect(data.count).to be 2
end
it "adds data for multiple columns" do
data = @course.custom_gradebook_columns.where(id: [@first_col.id, @second_col.id])
expect(data.count).to eql 2
expect(data.count).to be 2
end
it "does not create new columns when column doesn't exist" do
@ -83,7 +87,7 @@ describe Api::V1::CustomGradebookColumnDatum do
])
data = @course.custom_gradebook_columns.where(id: @second_col.id + 1001)
expect(data.count).to eql 0
expect(data.count).to be 0
end
it "updates the content for existing student and column" do
@ -100,7 +104,7 @@ describe Api::V1::CustomGradebookColumnDatum do
expect(data).to eql "2, 2"
end
it "can pass the column ID as a number" do
it "can also pass the column ID as a number" do
CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [
{
"column_id": @second_col.id,
@ -114,20 +118,6 @@ describe Api::V1::CustomGradebookColumnDatum do
expect(data).to eql "2, 2"
end
it "can pass the column ID as a string" do
CustomGradebookColumnDatum.process_bulk_update_custom_columns({}, @course, [
{
"column_id": @second_col.id.to_s,
"user_id": @second_student.id.to_s,
"content": "2, 2"
}
])
data = @course.custom_gradebook_columns.find_by!(id: @second_col.id).
custom_gradebook_column_data.find_by!(user_id: @second_student.id).content
expect(data).to eql "2, 2"
end
it "does not update content in deleted columns" do
@course.custom_gradebook_columns.find_by!(id: @second_col.id).
custom_gradebook_column_data.find_by!(user_id: @first_student.id).delete
@ -144,7 +134,7 @@ describe Api::V1::CustomGradebookColumnDatum do
])
data = @course.custom_gradebook_columns.where(id: @second_col.id)
expect(data.count).to eql 0
expect(data.count).to be 0
end
it "destroys data when uploading empty string" do
@ -158,7 +148,7 @@ describe Api::V1::CustomGradebookColumnDatum do
data = @course.custom_gradebook_columns.find_by!(id: @first_col.id).
custom_gradebook_column_data.find_by(user_id: @first_student.id)
expect(data).to eql nil
expect(data).to be_nil
end
end
end