diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 14281e6..1258d3c 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -39,4 +39,4 @@ def find_course rescue ActiveRecord::RecordNotFound redirect_to(root_url, alert: "Couldn't find course") end -end \ No newline at end of file +end diff --git a/db/schema.rb b/db/schema.rb index a751150..4951ebe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120316003602) do +ActiveRecord::Schema.define(:version => 20120316053737) do + create_table "course_memberships", :force => true do |t| t.integer "course_id" t.string "person_github_nickname" @@ -27,13 +28,6 @@ t.datetime "updated_at", :null => false end - create_table "tasks", :force => true do |t| - t.integer "course_id" - t.string "description" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "discussions", :force => true do |t| t.string "category" t.text "subject" @@ -42,4 +36,12 @@ t.datetime "created_at", :null => false t.datetime "updated_at", :null => false end -end \ No newline at end of file + + create_table "tasks", :force => true do |t| + t.integer "course_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + +end diff --git a/test/factories/course_memberships.rb b/test/factories/course_memberships.rb new file mode 100644 index 0000000..b758b3f --- /dev/null +++ b/test/factories/course_memberships.rb @@ -0,0 +1,8 @@ +FactoryGirl.define do + factory :instructor, class: CourseMembership do + association :course, factory: 'webdev' + person_github_nickname 'instructor' + role 'Instructor' + end +end + diff --git a/test/factories/courses.rb b/test/factories/courses.rb new file mode 100644 index 0000000..923497d --- /dev/null +++ b/test/factories/courses.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :webdev, class: Course do + name "Web Development" + description "MU's Web Development Course" + end +end diff --git a/test/fixtures/course_memberships.yml b/test/fixtures/course_memberships.yml deleted file mode 100644 index ecc80b0..0000000 --- a/test/fixtures/course_memberships.yml +++ /dev/null @@ -1,5 +0,0 @@ -instructor: - course: webdev - person_github_nickname: instructor - role: Instructor - diff --git a/test/fixtures/courses.yml b/test/fixtures/courses.yml deleted file mode 100644 index 7fa7d66..0000000 --- a/test/fixtures/courses.yml +++ /dev/null @@ -1,3 +0,0 @@ -webdev: - name: "Web Development" - description: "MU's Web Development Course" \ No newline at end of file diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 2b69ddb..c0a4212 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -1,22 +1,23 @@ require "test_helper" class TasksControllerTest < ActionController::TestCase - fixtures :all def setup + cm = Factory(:instructor) + @course = cm.course @controller.current_person = clubhouse_person("instructor") end test "#new is not allowed to students" do @controller.current_person = clubhouse_person("student") - get(:new, course_id: courses(:webdev).id) - assert_redirected_to(courses(:webdev)) + get(:new, course_id: @course.id) + assert_redirected_to(@course) assert flash[:alert] end test "#new is allowed to instructors" do - get(:new, course_id: courses(:webdev).id) + get(:new, course_id: @course.id) assert_template "new" end @@ -25,4 +26,4 @@ def setup assert_redirected_to(root_url) assert flash[:alert] end -end \ No newline at end of file +end diff --git a/test/integration/tasks_test.rb b/test/integration/tasks_test.rb index 0cc7669..f575174 100644 --- a/test/integration/tasks_test.rb +++ b/test/integration/tasks_test.rb @@ -1,8 +1,6 @@ require "test_helper" class TasksTest < ActionDispatch::IntegrationTest - fixtures :all - test "an instructor can create a new course task" do sign_in_as_instructor diff --git a/test/test_helper.rb b/test/test_helper.rb index f7d8cb9..60d017f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,6 @@ ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' - require "capybara/rails" Clubhouse::Client.test_mode = true @@ -12,11 +11,11 @@ def clubhouse_person(github_nickname) end class ActiveSupport::TestCase - fixtures :all end class ActionDispatch::IntegrationTest include Capybara::DSL + setup { Factory(:instructor) } teardown { Capybara.reset_sessions! } def sign_in_as_instructor @@ -35,4 +34,4 @@ def sign_in(person) click_button "Sign In" assert_includes(page.body, "Welcome to Liskov") end -end \ No newline at end of file +end