Skip to content

Commit fba362e

Browse files
committed
require title description when creating questions, updated controller spec to match
1 parent b20e776 commit fba362e

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

app/models/question.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ class Question
66

77
belongs_to :user
88

9+
validates_presence_of :title, :description
10+
911
end

spec/controllers/questions_controller_spec.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@
2424
# Question. As you add validations to Question, be sure to
2525
# update the return value of this method accordingly.
2626
def valid_attributes
27-
{}
27+
{
28+
:title => "Title",
29+
:description => "Description",
30+
:user => @user
31+
}
32+
end
33+
34+
before(:each) do
35+
@user = User.create!(:username => "test", :email => "test@example.com", :password => "password", :password_confirmation => "password")
36+
sign_in @user
2837
end
2938

3039
describe "GET index" do

0 commit comments

Comments
 (0)