-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Blair Anderson
committed
Mar 10, 2015
1 parent
5250bf6
commit fa37fd5
Showing
10 changed files
with
174 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class ItemCommentSerializer < ActiveModel::Serializer | ||
# self.per_page = 1 | ||
|
||
# has_scope :newest, type: :boolean | ||
# has_scope :disabled, type: :boolean | ||
# has_scope :by_degree | ||
# has_scope :by_period, :using => [:started_at, :ended_at], :type => :hash | ||
|
||
|
||
# filter #(optional) - Filters are used to narrow down the events used in an analysis request based on event property values. | ||
# timeframe #(optional) - A Timeframe specifies the events to use for analysis based on a window of time. | ||
# property_names #(optional) - A URL-encoded array of strings containing properties you wish to extract. If this parameter is omitted, all properties will be returned. | ||
|
||
# cache key: 'posts', expires_in: 3.hours | ||
attributes :id, :content, :user_id, :item_id, :created_at, :updated_at | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
resources: 'items', | ||
do: [ | ||
{ | ||
resources: 'comments' | ||
resources: 'item_comments', | ||
} | ||
] | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
require 'rails_helper' | ||
require 'rspec_api_documentation/dsl' | ||
|
||
resource "users" do | ||
get "/user" do | ||
example "Current User Resource" do | ||
user = FactoryGirl.create(:user, password: "password", password_confirmation: "password") | ||
login_user_post(user.username, "password") | ||
get "/user" | ||
status.should == 200 | ||
end | ||
end | ||
|
||
get "/user/:username" do | ||
example "User Resource" do | ||
user = FactoryGirl.create(:user) | ||
get "users/#{user.username}" | ||
status.should == 200 | ||
end | ||
end | ||
end | ||
# resource "users" do | ||
# get "/user" do | ||
# example "Current User Resource" do | ||
# user = FactoryGirl.create(:user, password: "password", password_confirmation: "password") | ||
# login_user_post(user.username, "password") | ||
# get "/user" | ||
# status.should == 200 | ||
# end | ||
# end | ||
# | ||
# get "/user/:username" do | ||
# example "User Resource" do | ||
# user = FactoryGirl.create(:user) | ||
# get "users/#{user.username}" | ||
# status.should == 200 | ||
# end | ||
# end | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :item_comment do | ||
item | ||
user | ||
content {Faker::Company.bs[0..250]} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FactoryGirl.define do | ||
factory :item do | ||
user | ||
title {Faker::Company.bs[0..250]} | ||
url {Faker::Internet.url} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'rails_helper' | ||
|
||
|
||
|
||
describe ActiveApi, 'item_comments' do | ||
|
||
describe "GET /items/:item_id/item_comments" do | ||
before do | ||
|
||
end | ||
it 'sends a list of comments for a given item' do | ||
item = FactoryGirl.create(:item) | ||
|
||
length = 10 | ||
FactoryGirl.create_list(:item_comment, length, item: item) | ||
|
||
get active_api_path + "items/#{item.id}/item_comments?parent_resource=foo" | ||
expect(response).to be_success | ||
expect(json['item_comments'].length).to eq(length) # check to make sure the right amount of messages are returned | ||
end | ||
|
||
end | ||
|
||
describe "POST /items/:item_id/item_comments" do | ||
it 'allows an authenticated user to create a comment' | ||
end | ||
|
||
describe "GET /items/:item_id/item_comments/:id" do | ||
it 'sends a single comment for a given item.' | ||
end | ||
|
||
describe "PATCH /items/:item_id/item_comments/:id" do | ||
it 'allows an authenticated user to update a comment' | ||
end | ||
|
||
describe "PUT /items/:item_id/item_comments/:id" do | ||
it 'allows an authenticated user to update a comment' | ||
end | ||
|
||
describe "DELETE /items/:item_id/item_comments/:id" do | ||
it 'allows an authenticated user to delete a comment' | ||
end | ||
|
||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'rails_helper' | ||
|
||
|
||
describe ActiveApi, "items" do | ||
describe "GET /items" do | ||
it 'sends a list of items' do | ||
length = 10 | ||
|
||
FactoryGirl.create_list(:item, length) | ||
|
||
get active_api_path + "items" | ||
expect(response).to be_success # test for the 200 status-code | ||
expect(json['items'].length).to eq(length) # check to make sure the right amount of messages are returned | ||
end | ||
end | ||
|
||
describe "GET /items/:id" do | ||
it 'sends an item' | ||
end | ||
|
||
describe "POST /items" do | ||
it 'lets an authenticated user create an item' | ||
end | ||
|
||
describe "PATCH /items/:id" do | ||
it 'lets an authenticated user update an item' | ||
end | ||
|
||
describe "PUT /items/:id" do | ||
it 'lets an authenticated user update an item' | ||
end | ||
|
||
describe "DELETE /items/:id" do | ||
it 'lets an authenticated user delete an item' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'rails_helper' | ||
|
||
describe ActiveApi, 'users' do | ||
describe 'GET /users' do | ||
it 'sends a list of users' do | ||
length = 10 | ||
|
||
FactoryGirl.create_list(:user, length) | ||
|
||
get active_api_path + 'users' | ||
expect(response).to be_success # test for the 200 status-code | ||
expect(json['users'].length).to eq(length) # check to make sure the right amount of messages are returned | ||
end | ||
end | ||
|
||
describe 'GET /users/:id' do | ||
it 'sends a user' | ||
end | ||
|
||
describe 'POST /users' do | ||
it 'lets you create an account' | ||
end | ||
|
||
describe 'PATCH /users/:id' do | ||
it 'allows an authenticated user to update their account.' | ||
end | ||
|
||
describe 'PUT /users/:id' do | ||
it 'allows an authenticated user to update their account.' | ||
end | ||
|
||
describe 'DELETE /users/:id' do | ||
it 'allows an authenticated user to delete their account.' | ||
end | ||
|
||
end |