Skip to content

Commit

Permalink
show submission like on submission list #1
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Jul 16, 2015
1 parent acf9cd4 commit 12a90de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions applications/api.moon
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ format_submission = do
upload\image_url!
} for upload in *s.uploads]

out.submission_like = if s.submission_like
{
created_at: s.submission_like.created_at
}

out

format_streak = do
Expand Down
12 changes: 9 additions & 3 deletions spec/applications/api_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import request from require "spec.helpers"

import truncate_tables from require "lapis.spec.db"
import ApiKeys, Users, Streaks, StreakUsers, Submissions, StreakSubmissions,
Uploads from require "models"
Uploads, SubmissionLikes from require "models"

factory = require "spec.factory"

Expand All @@ -20,7 +20,7 @@ describe "api", ->

before_each ->
truncate_tables Users, ApiKeys, Streaks, StreakUsers, Submissions,
StreakSubmissions, Uploads
StreakSubmissions, Uploads, SubmissionLikes

it "it should create api key", ->
assert factory.ApiKeys!
Expand Down Expand Up @@ -170,7 +170,7 @@ describe "api", ->
assert.truthy res.submissions
assert.same 2, #res.submissions

it "views streak submissions with upload", ->
it "views streak submissions with upload and like", ->
streak = factory.Streaks!
streak_sub = factory.StreakSubmissions streak_id: streak.id
submission = streak_sub\get_submission!
Expand All @@ -183,7 +183,13 @@ describe "api", ->
ready: true
}

SubmissionLikes\create {
submission_id: submission.id
user_id: current_user.id
}

status, res = request_with_key "/api/1/streak/#{streak.id}/submissions"
assert.truthy res.submissions
assert.same 1, #res.submissions[1].uploads
assert.truthy res.submissions[1].submission_like

0 comments on commit 12a90de

Please sign in to comment.