-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
7445619
commit f8da606
Showing
7 changed files
with
95 additions
and
8 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,10 @@ | ||
module Api | ||
module UsingNothing | ||
class ArtworksController < ApplicationController | ||
def index | ||
artworks = Artwork.all | ||
render json: artworks | ||
end | ||
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,2 @@ | ||
class Artwork < ApplicationRecord | ||
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 |
---|---|---|
@@ -1,10 +1,7 @@ | ||
Rails.application.routes.draw do | ||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html | ||
|
||
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. | ||
# Can be used by load balancers and uptime monitors to verify that the app is live. | ||
get "up" => "rails/health#show", :as => :rails_health_check | ||
|
||
# Defines the root path route ("/") | ||
# root "posts#index" | ||
namespace :api do | ||
namespace :using_nothing do | ||
resources :artworks | ||
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 @@ | ||
class CreateArtworks < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :artworks do |t| | ||
t.string :artist_name | ||
t.string :title | ||
t.string :medium | ||
t.integer :amount_cents | ||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
FactoryBot.define do | ||
factory :artwork do | ||
amount_cents { 77_000 } | ||
artist_name { "Polly Painter" } | ||
medium { "Very wet paint" } | ||
title { "Just like some flowers or whatever" } | ||
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,33 @@ | ||
require "rails_helper" | ||
|
||
describe "/api/using_nothing/artworks" do | ||
context "without any artworks" do | ||
it "returns an empty array" do | ||
get "/api/using_nothing/artworks" | ||
expect(response.status).to eq 200 | ||
expect(response.parsed_body).to eq [] | ||
end | ||
end | ||
|
||
context "with an artwork" do | ||
let!(:artwork) { FactoryBot.create(:artwork) } | ||
|
||
it "returns that artwork" do | ||
get "/api/using_nothing/artworks" | ||
expect(response.status).to eq 200 | ||
expect(response.parsed_body).to eq [artwork].as_json | ||
end | ||
end | ||
|
||
context "with a few artworks" do | ||
before do | ||
FactoryBot.create_list(:artwork, 3) | ||
end | ||
|
||
it "returns those artworks" do | ||
get "/api/using_nothing/artworks" | ||
expect(response.status).to eq 200 | ||
expect(response.parsed_body.count).to eq 3 | ||
end | ||
end | ||
end |