Skip to content

Instantly share code, notes, and snippets.

@yawboakye
Created September 13, 2016 14:56
Show Gist options
  • Save yawboakye/0d3b8e08268e26159ed5208af439990d to your computer and use it in GitHub Desktop.
Save yawboakye/0d3b8e08268e26159ed5208af439990d to your computer and use it in GitHub Desktop.
# fixture
one:
type: TextTimelineItem
item_text: Hello, hello, happiness
# controller test
test "should create comment for a commentable" do
t = text_timeline_items(:one)
# t.id changes for every test :(
post comments_url,
params: { content: "Congratulations", "commentable_type": "TextTimelineItem", "commentable_id": t.id },
as: :json
assert_response :created
end
# schema.rb
create_table "comments", id: :uuid, default: -> { "gen_random_uuid()" } do
t.uuid commentable_id
t.text commentable_type
t.text content
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment