Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue 569 #1

Merged
merged 1 commit into from

2 participants

@NelleV

Here's a few modifications on the tests.

I'll merge your patch as soon as you've validated my changes :)

@lkysow lkysow merged commit 4872325 into lkysow:issue-569
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 40 additions and 40 deletions.
  1. +40 −40 test/functional/assignments_controller_test.rb
View
80 test/functional/assignments_controller_test.rb
@@ -64,9 +64,6 @@ def teardown
post_as @admin, :create, @attributes
new_assignment = Assignment.find_by_short_identifier(@short_identifier)
assert_not_nil new_assignment.assignment_stat
- end
-
- should "redirect and set flash" do
assert respond_with :redirect
assert set_the_flash
end
@@ -76,50 +73,53 @@ def teardown
new_assignment = Assignment.find_by_short_identifier(@short_identifier)
assert_equal flash[:success], "Successfully created the assignment"
end
-
+
context "with section due dates" do
setup do
- @attributes["section_due_dates_type"] = "1"
- @attributes["section_due_dates_attributes"] =
- {"0"=>{"section_id"=>"2", "due_date"=>"2011-10-27 00:00"},
- "1"=>{"section_id"=>"3", "due_date"=>"2011-10-27 00:00"}}
@section1 = Section.make
@section2 = Section.make
- @due_date_attributes = {"0"=>{"section_id"=>"#{@section1.id}", "due_date"=>"2011-10-27 00:00"},
- "1"=>{"section_id"=>"#{@section2.id}", "due_date"=>"2011-10-29 00:00"}}
- @attributes["assignment"]["section_due_dates_attributes"] = @due_date_attributes
end
-
- context "with section_due_dates_type selected" do
- should "save assignment with correct parameters" do
- post_as @admin, :create, @attributes
- new_assignment = Assignment.find_by_short_identifier(@short_identifier)
- assert_not_nil new_assignment
- assert_equal true, new_assignment.section_due_dates_type
- @due_date_attributes.each do |key, value|
- assert new_assignment.section_due_dates[Integer(key)].due_date.to_s.include?( value["due_date"] )
- end
- assert redirect_to(:action => "edit", :id => new_assignment)
- end
-
- context "with one section due date not specified" do
- setup do
- @attributes["assignment"]["section_due_dates_attributes"]["0"]["due_date"] = nil
- @due_date_attributes["0"]["due_date"] = nil
- end
-
- should "save assignment with correct parameters" do
- post_as @admin, :create, @attributes
- new_assignment = Assignment.find_by_short_identifier(@short_identifier)
- assert_not_nil new_assignment
- assert_equal true, new_assignment.section_due_dates_type
- assert_nil new_assignment.section_due_dates[0].due_date
- assert new_assignment.section_due_dates[1].due_date.to_s.include? @due_date_attributes["1"]["due_date"]
- assert redirect_to(:action => "edit", :id => new_assignment)
- end
+
+ should "be able to create assignment with section due dates" do
+ @attributes["section_due_dates_type"] = "1"
+ due_date_attributes = {
+ "0" => {"section_id" => "#{@section1.id}",
+ "due_date" => "2011-10-27 00:00"},
+ "1" => {"section_id" => "#{@section2.id}",
+ "due_date"=>"2011-10-29 00:00"}}
+ @attributes["assignment"]["section_due_dates_attributes"] = due_date_attributes
+
+ post_as @admin, :create, @attributes
+ new_assignment = Assignment.find_by_short_identifier(@short_identifier)
+ assert_not_nil new_assignment
+ assert_equal true, new_assignment.section_due_dates_type
+ due_date_attributes.each do |key, value|
+ assert new_assignment.section_due_dates[Integer(
+ key)].due_date.to_s.include?(value["due_date"])
end
+ assert redirect_to(:action => "edit", :id => new_assignment)
end
- end
+
+ should "be able to create assignment due date with some section due dates set" do
+ # A section due date can be nil
+ # That section then uses the main due_date
+ @attributes["section_due_dates_type"] = "1"
+ due_date_attributes = {
+ "0" => {"section_id" => "#{@section1.id}",
+ "due_date" => nil},
+ "1" => {"section_id" => "#{@section2.id}",
+ "due_date"=>"2011-10-29 00:00"}}
+ @attributes["assignment"]["section_due_dates_attributes"] = due_date_attributes
+
+ post_as @admin, :create, @attributes
+ new_assignment = Assignment.find_by_short_identifier(@short_identifier)
+ assert_not_nil new_assignment
+ assert_equal true, new_assignment.section_due_dates_type
+ assert_nil new_assignment.section_due_dates[0].due_date
+ assert new_assignment.section_due_dates[1].due_date.to_s.include? due_date_attributes["1"]["due_date"]
+ assert redirect_to(:action => "edit", :id => new_assignment)
+ end
+ end # With some sections
end #creating new assignment
should "be able to get a new assignment form with submission rules HTML present" do
Something went wrong with that request. Please try again.