-
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
Showing
29 changed files
with
328 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,3 +75,7 @@ end | |
|
||
gem "devise", "~> 4.9" | ||
|
||
|
||
gem "view_component", "~> 3.14" | ||
|
||
gem "tailwindcss-rails", "~> 2.7" |
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,2 @@ | ||
web: bin/rails server | ||
css: bin/rails tailwindcss:watch |
Empty file.
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,13 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
/* | ||
@layer components { | ||
.btn-primary { | ||
@apply py-2 px-4 bg-blue-200; | ||
} | ||
} | ||
*/ |
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,5 @@ | ||
<footer class="bg-white shadow"> | ||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8"> | ||
<p class="text-sm text-gray-500">© 2024 Rugiet. All rights reserved.</p> | ||
</div> | ||
</footer> |
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 FooterComponent < ViewComponent::Base | ||
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,5 @@ | ||
<header class="bg-white shadow"> | ||
<div class="mx-auto max-w-7xl px-4 py-6 sm:px-6 lg:px-8"> | ||
<h1 class="text-3xl font-bold tracking-tight text-gray-900">Rugiet Take Home Coding Challenge</h1> | ||
</div> | ||
</header> |
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,4 @@ | ||
require "view_component" | ||
|
||
class HeaderComponent < ViewComponent::Base | ||
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,2 +1,3 @@ | ||
class ApplicationController < ActionController::Base | ||
before_action :authenticate_user! | ||
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,70 @@ | ||
class OrdersController < ApplicationController | ||
before_action :set_order, only: %i[ show edit update destroy ] | ||
|
||
# GET /orders or /orders.json | ||
def index | ||
@orders = Order.all | ||
end | ||
|
||
# GET /orders/1 or /orders/1.json | ||
def show | ||
end | ||
|
||
# GET /orders/new | ||
def new | ||
@order = Order.new | ||
end | ||
|
||
# GET /orders/1/edit | ||
def edit | ||
end | ||
|
||
# POST /orders or /orders.json | ||
def create | ||
@order = Order.new(order_params) | ||
|
||
respond_to do |format| | ||
if @order.save | ||
format.html { redirect_to @order, notice: "Order was successfully created." } | ||
format.json { render :show, status: :created, location: @order } | ||
else | ||
format.html { render :new, status: :unprocessable_entity } | ||
format.json { render json: @order.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /orders/1 or /orders/1.json | ||
def update | ||
respond_to do |format| | ||
if @order.update(order_params) | ||
format.html { redirect_to @order, notice: "Order was successfully updated." } | ||
format.json { render :show, status: :ok, location: @order } | ||
else | ||
format.html { render :edit, status: :unprocessable_entity } | ||
format.json { render json: @order.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /orders/1 or /orders/1.json | ||
def destroy | ||
@order.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to orders_path, status: :see_other, notice: "Order was successfully destroyed." } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_order | ||
@order = Order.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def order_params | ||
params.fetch(:order, {}) | ||
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 @@ | ||
module OrdersHelper | ||
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,16 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Takehome</title> | ||
<title>Rugiet Take Home Coding Challenge</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
<%= stylesheet_link_tag "tailwind", "inter-font", "data-turbo-track": "reload" %> | ||
|
||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> | ||
<%= javascript_importmap_tags %> | ||
</head> | ||
|
||
<body> | ||
<%= render HeaderComponent.new %> | ||
<%= yield %> | ||
<%= render FooterComponent.new %> | ||
</body> | ||
</html> |
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,17 @@ | ||
<%= form_with(model: order) do |form| %> | ||
<% if order.errors.any? %> | ||
<div style="color: red"> | ||
<h2><%= pluralize(order.errors.count, "error") %> prohibited this order from being saved:</h2> | ||
|
||
<ul> | ||
<% order.errors.each do |error| %> | ||
<li><%= error.full_message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div> | ||
<%= form.submit %> | ||
</div> | ||
<% 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 @@ | ||
<div id="<%= dom_id order %>"> | ||
</div> |
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 @@ | ||
json.extract! order, :id, :created_at, :updated_at | ||
json.url order_url(order, format: :json) |
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 @@ | ||
<h1>Editing order</h1> | ||
|
||
<%= render "form", order: @order %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Show this order", @order %> | | ||
<%= link_to "Back to orders", orders_path %> | ||
</div> |
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,14 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<h1>Orders</h1> | ||
|
||
<div id="orders"> | ||
<% @orders.each do |order| %> | ||
<%= render order %> | ||
<p> | ||
<%= link_to "Show this order", order %> | ||
</p> | ||
<% end %> | ||
</div> | ||
|
||
<%= link_to "New order", new_order_path %> |
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 @@ | ||
json.array! @orders, partial: "orders/order", as: :order |
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,9 @@ | ||
<h1>New order</h1> | ||
|
||
<%= render "form", order: @order %> | ||
|
||
<br> | ||
|
||
<div> | ||
<%= link_to "Back to orders", orders_path %> | ||
</div> |
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 @@ | ||
<p style="color: green"><%= notice %></p> | ||
|
||
<%= render @order %> | ||
|
||
<div> | ||
<%= link_to "Edit this order", edit_order_path(@order) %> | | ||
<%= link_to "Back to orders", orders_path %> | ||
|
||
<%= button_to "Destroy this order", @order, method: :delete %> | ||
</div> |
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 @@ | ||
json.partial! "orders/order", order: @order |
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 @@ | ||
#!/usr/bin/env sh | ||
|
||
if ! gem list foreman -i --silent; then | ||
echo "Installing foreman..." | ||
gem install foreman | ||
fi | ||
|
||
# Default to port 3000 if not specified | ||
export PORT="${PORT:-3000}" | ||
|
||
# Let the debug gem allow remote connections, | ||
# but avoid loading until `debugger` is called | ||
export RUBY_DEBUG_OPEN="true" | ||
export RUBY_DEBUG_LAZY="true" | ||
|
||
exec foreman start -f Procfile.dev "$@" |
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,7 +1,8 @@ | ||
Rails.application.routes.draw do | ||
resources :orders | ||
devise_for :users | ||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html | ||
|
||
# Defines the root path route ("/") | ||
# root "articles#index" | ||
root "orders#index" | ||
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,23 @@ | ||
const defaultTheme = require('tailwindcss/defaultTheme') | ||
|
||
module.exports = { | ||
content: [ | ||
'./public/*.html', | ||
'./app/helpers/**/*.rb', | ||
'./app/javascript/**/*.js', | ||
'./app/views/**/*.{erb,haml,html,slim}', | ||
'./app/components/**/*.{erb,haml,html,slim}', | ||
], | ||
theme: { | ||
extend: { | ||
fontFamily: { | ||
sans: ['Inter var', ...defaultTheme.fontFamily.sans], | ||
}, | ||
}, | ||
}, | ||
plugins: [ | ||
require('@tailwindcss/forms'), | ||
require('@tailwindcss/typography'), | ||
require('@tailwindcss/container-queries'), | ||
] | ||
} |
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,48 @@ | ||
require "test_helper" | ||
|
||
class OrdersControllerTest < ActionDispatch::IntegrationTest | ||
setup do | ||
@order = orders(:one) | ||
end | ||
|
||
test "should get index" do | ||
get orders_url | ||
assert_response :success | ||
end | ||
|
||
test "should get new" do | ||
get new_order_url | ||
assert_response :success | ||
end | ||
|
||
test "should create order" do | ||
assert_difference("Order.count") do | ||
post orders_url, params: { order: { } } | ||
end | ||
|
||
assert_redirected_to order_url(Order.last) | ||
end | ||
|
||
test "should show order" do | ||
get order_url(@order) | ||
assert_response :success | ||
end | ||
|
||
test "should get edit" do | ||
get edit_order_url(@order) | ||
assert_response :success | ||
end | ||
|
||
test "should update order" do | ||
patch order_url(@order), params: { order: { } } | ||
assert_redirected_to order_url(@order) | ||
end | ||
|
||
test "should destroy order" do | ||
assert_difference("Order.count", -1) do | ||
delete order_url(@order) | ||
end | ||
|
||
assert_redirected_to orders_url | ||
end | ||
end |
Oops, something went wrong.