-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
8 changed files
with
65 additions
and
6 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
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
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,42 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe TagsController, type: :request do | ||
|
||
let(:user) { valid_user } | ||
before :each do | ||
create_tags | ||
end | ||
|
||
describe "GET /tags/popular" do | ||
it "returns 200 status and popular tags" do | ||
|
||
get popular_tags_path, {format: :json}, authorization_header | ||
|
||
expect(parsed_json).to have_key("contract") | ||
expect(status).to eq 200 | ||
end | ||
end | ||
|
||
describe "GET /tags/recent" do | ||
it "returns 200 status and recent tags" do | ||
|
||
get recent_tags_path, {format: :json}, authorization_header | ||
|
||
expect(parsed_json.first["id"]).to eq(Tag.last.id) | ||
expect(parsed_json.last["id"]).to eq(Tag.first.id) | ||
expect(parsed_json.count).to eq(Tag.count) | ||
expect(status).to eq 200 | ||
end | ||
end | ||
|
||
describe "GET /tags/trending" do | ||
it "returns 200 status and trending tags" do | ||
|
||
get trending_tags_path, {format: :json}, authorization_header | ||
|
||
expect(parsed_json.first.last).to eq(parsed_json.values.max) | ||
expect(status).to eq 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,11 @@ | ||
module CreateResource | ||
def create_tags | ||
5.times { create(:tag, name: "Contract", created_at: 4.days.ago) } | ||
3.times { create(:tag, name: "Amity", created_at: 2.days.ago) } | ||
2.times { create(:tag, name: "Kaizen") } | ||
end | ||
end | ||
|
||
RSpec.configure do |config| | ||
config.include CreateResource | ||
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 |
---|---|---|
|
@@ -6,6 +6,10 @@ def parsed_json | |
def body | ||
response.body | ||
end | ||
|
||
def status | ||
response.status | ||
end | ||
end | ||
|
||
|
||
|