Sha256: 275c8e97c42d9330b94826ac6c2c063084cf32e8338435c0601a3d4326b61623

Contents?: true

Size: 1.89 KB

Versions: 52

Compression:

Stored size: 1.89 KB

Contents

require 'helper'

describe Bearcat::Client::Assignments do
  before do
    @client = Bearcat::Client.new(prefix: "http://canvas.instructure.com", token: "test_token")
  end

  it "returns all assignments for a course" do
    stub_get(@client, "/api/v1/courses/3/assignments").to_return(json_response("assignments.json"))
    assignments = @client.assignments(3)
    assignments.count.should == 2
    assignments.first["assignment_group_id"].should == 53
    assignments.first["id"].should == 123
    assignments.first["due_at"].should == nil
  end

  it "returns an individual assignment for a course" do
    stub_get(@client, "/api/v1/courses/3/assignments/1").to_return(json_response("assignment.json"))
    assignment = @client.assignment(3, 1)
    assignment["assignment_group_id"].should == 53
    assignment["id"].should == 1
    assignment["due_at"].should == nil
  end

  it "creates an assignment override for a section" do
    stub_post(@client, "/api/v1/courses/310/assignments/123/overrides")
      .with(:body => {"assignment_override"=>{"course_section_id"=>"74", "due_at"=>"2013-06-27T21:08:46Z"}})
      .to_return(json_response("assignment_section_override.json"))
    override = @client.create_assignment_override(310, 123, {
      "assignment_override[course_section_id]" => 74,
      "assignment_override[due_at]" => "2013-06-27T21:08:46Z"
    })
    override["all_day"].should == false
    override["due_at"].should == "2013-06-27T15:08:46-06:00"
    override["id"].should == 1
    override["course_section_id"].should == 74
  end

  it "creates a new assignment" do
    name = "new assignment"
    stub_post(@client, "/api/v1/courses/1/assignments").with(body: {"assignment" => {"name" => name}}).to_return(json_response("created_assignment.json"))
    assignment = @client.create_assignment(1, {"assignment" => {"name" => name}})
    assignment["name"].should == name
    assignment["id"].should == 1
  end

end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
bearcat-1.3.19 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.18 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.17 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.16 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.15 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.14 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.13 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.12 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.11 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.10 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.9 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.8 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.7 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.6 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.5 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.4 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.3 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.2 spec/bearcat/client/assignments_spec.rb
bearcat-1.3.1 spec/bearcat/client/assignments_spec.rb
bearcat-1.2.18 spec/bearcat/client/assignments_spec.rb