Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3 from wicz/factory_girl

Factory girl
  • Loading branch information...
commit 1e4ab283ef3b81287f97f897a041ce49bb0e6603 2 parents bffcdc8 + fe8476a
@wicz wicz authored
View
2  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
+end
View
20 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
+
+ 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
View
8 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
+
View
6 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
View
5 test/fixtures/course_memberships.yml
@@ -1,5 +0,0 @@
-instructor:
- course: webdev
- person_github_nickname: instructor
- role: Instructor
-
View
3  test/fixtures/courses.yml
@@ -1,3 +0,0 @@
-webdev:
- name: "Web Development"
- description: "MU's Web Development Course"
View
11 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
+end
View
2  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
View
5 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
+end
Please sign in to comment.
Something went wrong with that request. Please try again.