diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -1,6 +1,7 @@ class Problem < ActiveRecord::Base belongs_to :description + has_many :test_pairs validates_presence_of :name validates_format_of :name, :with => /^\w+$/ diff --git a/app/models/test_pair.rb b/app/models/test_pair.rb new file mode 100644 --- /dev/null +++ b/app/models/test_pair.rb @@ -0,0 +1,3 @@ +class TestPair < ActiveRecord::Base + belongs_to :problem +end diff --git a/db/migrate/20100113094740_create_test_pairs.rb b/db/migrate/20100113094740_create_test_pairs.rb new file mode 100644 --- /dev/null +++ b/db/migrate/20100113094740_create_test_pairs.rb @@ -0,0 +1,15 @@ +class CreateTestPairs < ActiveRecord::Migration + def self.up + create_table :test_pairs do |t| + t.integer :problem_id + t.text :input + t.text :solution + + t.timestamps + end + end + + def self.down + drop_table :test_pairs + end +end diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20090815171610) do +ActiveRecord::Schema.define(:version => 20100113094740) do create_table "announcements", :force => true do |t| t.string "author" @@ -155,6 +155,14 @@ t.datetime "updated_at" end + create_table "test_pairs", :force => true do |t| + t.integer "problem_id" + t.text "input" + t.text "solution" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "test_requests", :force => true do |t| t.integer "user_id" t.integer "problem_id" diff --git a/test/fixtures/test_pairs.yml b/test/fixtures/test_pairs.yml new file mode 100644 --- /dev/null +++ b/test/fixtures/test_pairs.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html + +one: + problem_id: 1 + input: MyText + solution: MyText + +two: + problem_id: 1 + input: MyText + solution: MyText diff --git a/test/unit/test_pair_test.rb b/test/unit/test_pair_test.rb new file mode 100644 --- /dev/null +++ b/test/unit/test_pair_test.rb @@ -0,0 +1,8 @@ +require 'test_helper' + +class TestPairTest < ActiveSupport::TestCase + # Replace this with your real tests. + test "the truth" do + assert true + end +end