Ensure report details are not blank.
This commit is contained in:
parent
d7612f42d0
commit
c00c515d9d
4 changed files with 17 additions and 4 deletions
|
@ -1,4 +1,6 @@
|
|||
class Report < ActiveRecord::Base
|
||||
belongs_to :issue, :counter_cache => true
|
||||
belongs_to :user, :class_name => "User", :foreign_key => :reporter_user_id
|
||||
|
||||
validates :details, :presence => true
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ class CreateIssuesAndReports < ActiveRecord::Migration
|
|||
create_table :reports do |t|
|
||||
t.integer :issue_id
|
||||
t.integer :reporter_user_id
|
||||
t.text :details
|
||||
t.text :details, :null => false
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
|
||||
|
|
7
test/factories/reports.rb
Normal file
7
test/factories/reports.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
FactoryGirl.define do
|
||||
factory :report do
|
||||
sequence(:details) { |n| "Report details #{n}" }
|
||||
issue
|
||||
user
|
||||
end
|
||||
end
|
|
@ -1,7 +1,11 @@
|
|||
require "test_helper"
|
||||
|
||||
class ReportTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
def test_details_required
|
||||
report = create(:report)
|
||||
|
||||
assert report.valid?
|
||||
report.details = ''
|
||||
assert !report.valid?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue