Skip to content

Commit

Permalink
refs #1 titleを必須にする kindのデフォルトをproblemにする
Browse files Browse the repository at this point in the history
  • Loading branch information
hamapu committed Sep 28, 2019
1 parent 041070d commit d87f10a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions db/migrate/20190918012131_create_issues.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class CreateIssues < ActiveRecord::Migration[5.2]
def change
create_table :issues do |t|
t.string :title
t.string :title, null: false
t.text :body
t.integer :kind
t.integer :kind, default: 3

t.timestamps
end
Expand Down
19 changes: 18 additions & 1 deletion spec/requests/issues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,22 @@
it { expect(response.code).to eq "200" }
it { expect(response_body.payload.body).to eq "body" }
end


describe "#01:title must be a required field" do
let(:params) {
{ issue: { body: "body", kind: :try } }
}
it { expect{ post "/issues", params: params }.to raise_error(ActiveRecord::NotNullViolation) }
end

describe "#01:default value of kind must be problem" do
let(:params) {
{ issue: { title: "title", body: "body" } }
}
before { post "/issues", params: params }
let(:response_body) { JSON.parse(response.body, object_class: OpenStruct) }
it { expect(response.code).to eq "200" }
it { expect(response_body.payload.kind).to eq "problem" }
end

end

0 comments on commit d87f10a

Please sign in to comment.