diff --git a/app/assets/stylesheets/_config.css b/app/assets/stylesheets/_config.css new file mode 100644 index 0000000..bfdb063 --- /dev/null +++ b/app/assets/stylesheets/_config.css @@ -0,0 +1,119 @@ +* { + font-family: "Figtree", sans-serif; + margin: 0; + padding: 0; + box-sizing: border-box; + text-decoration: none; + list-style: none; + color: var(--color-text); +} + +body { + background-color: #f2f2f2; + height: 100vh; +} + +main { + display: flex; + justify-content: center; + align-items: flex-start; + width: 100%; + flex-wrap: wrap; + height: auto; +} + +:root { + /* colors */ + --color-main: #3778c2; + --color-second: #f21905; + --color-text: #353a40; + --color-third: #5fb523; +} + +.proxima-nova-bold { + font-weight: 700; + font-style: normal; +} + +.proxima-nova-light { + font-weight: 300; + font-style: normal; +} + +.container { + width: 100%; + max-width: 720px; +} + +.flex { + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} + +.btn-group { + width: 100%; +} + +.btn-main, +.btn-white { + padding: 0.75rem; + margin-top: 1rem; + background-color: var(--color-main); + width: 90%; + border-radius: 0.18rem; + text-align: center; + text-transform: uppercase; + color: white; + letter-spacing: 1px; + font-weight: 400; + cursor: pointer; + font-size: 18px; + border: none; + transition: all 100ms ease-out; +} + +.btn-white { + background-color: white; + color: var(--color-text); +} + +.btn-main:hover { + background-color: #87aeda; + text-shadow: 0 0 10px black; + opacity: 80%; +} + +.btn-white:hover { + background-color: var(--color-third); + color: white; + text-shadow: 0 0 10px black; + opacity: 80%; +} + +.title { + width: 100%; + text-align: center; + font-size: 20px; + font-weight: 300; + background-color: white; + padding: 0.75rem 0; +} + +.inner-container { + width: 100%; + margin-top: 1rem; +} + +.card { + justify-content: space-between; + align-items: center; + padding: 10px 12px; +} + +.inner-card { + display: flex; + flex-direction: column; + gap: 10px; +} diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index a200c7f..288b9ab 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -13,316 +13,3 @@ *= require_tree . *= require_self */ - -:root { - --blue: #3778c2; - --gray: #434b54; - --green: #5fb523; -} - -* { - font-family: "Figtree", sans-serif; - margin: 0; - padding: 0; - list-style: none; - text-decoration: none; -} - -/* body { - height: 100vh; -} */ - -/* Splash screen */ - -.splash { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - width: 100%; - height: 100vh; -} - -.splash-logo { - width: 22rem; - margin-top: auto; - margin-bottom: auto; -} - -.splash-btn { - margin-top: auto; - margin-bottom: 2rem; - display: flex; - flex-direction: column; - gap: 1.3rem; - width: 100%; - justify-content: center; - align-items: center; -} - -.login-btn { - background-color: var(--blue); - text-decoration: none; - color: white; - border-radius: 5px; - padding: 10px; - width: 75%; - text-align: center; - font-size: 1.3rem; -} - -.signup-btn { - color: var(--gray); - font-size: 1.3rem; -} - -/* Sign-up page */ - -form { - width: 100%; - height: 50%; -} - -.sign-up-header, -nav { - height: 3.5rem; - background-color: var(--blue); - color: white; - display: flex; - justify-content: space-between; - padding: 0.2rem 0.8rem; - align-items: center; -} - -.go-back { - color: white; - font-size: 1rem; -} - -.submit input { - background-color: transparent; - border: none; - color: white; - font-size: 1rem; -} - -.shared-links { - display: flex; - justify-content: center; - align-items: center; - flex-wrap: wrap; -} - -.form-inputs { - margin-top: 1rem; - width: 90%; - display: flex; - flex-direction: column; - gap: 1rem; - padding: 1rem; -} - -.div-input { - margin: 0.15rem 0; - width: 100%; - display: flex; - justify-content: center; - flex-direction: column; -} - -.div-input input { - height: 2rem; -} - -.check-box { - display: flex; - flex-direction: row; - align-items: center; - gap: 1rem; - justify-content: flex-start; -} - -/* Groups index page */ - -.groups-index { - display: flex; - margin-top: 1rem; - flex-direction: column; - align-items: center; - justify-content: center; -} - -.groups-index h1 { - font-weight: 700; - font-size: 2rem; - color: var(--gray); -} - -.groups-index a { - margin-top: 0.5rem; - font-weight: 700; - font-size: 1rem; - color: white; - padding: 5px; - border-radius: 3px; - background-color: var(--green); - text-align: center; -} - -#groups { - width: 100%; - display: flex; - flex-direction: column; - gap: 1rem; - align-items: center; - margin-top: 2rem; -} - -/* single Group */ - -.single-group { - height: 3rem; - padding: 5px; - width: 90%; - display: grid; - align-items: center; - grid-template-columns: 20% 50% 30%; - background-color: rgb(225, 225, 225); -} - -.single-group p { - font-size: 1.8rem; - margin: 0; -} - -.group-price { - margin-left: auto; - font-size: 1.3rem; - color: var(--green); - font-weight: 700; -} - -#group_icon { - height: 2.7rem; - font-size: 2rem; - width: 30%; - border-radius: 5px; -} - -.submit-btn input { - border: none; - margin-top: 0.5rem; - font-weight: 700; - font-size: 1rem; - color: white; - padding: 5px; - border-radius: 3px; - background-color: var(--green); -} - -/* group show */ - -.group-options-btns { - display: flex; - margin-top: 1rem; - width: 90%; - justify-content: space-between; - gap: 5px; -} - -.button_to { - width: auto; -} - -.button_to button { - background-color: red; - border: none; - margin-top: 0.5rem; - font-weight: 700; - font-size: 1rem; - color: white; - padding: 5px; - border-radius: 3px; -} - -#expenses { - width: 100%; - margin-top: 2rem; - display: flex; - flex-direction: column; - align-items: center; - gap: 1rem; -} - -.expenses { - width: 100%; - margin-top: 2rem; - display: flex; - flex-direction: column; - align-items: center; - gap: 1rem; -} - -.expense { - height: 4rem; - padding: 5px; - width: 90%; - display: flex; - flex-direction: column; - align-items: center; - background-color: rgb(225, 225, 225); -} - -.expense-main, -.expense-info { - display: flex; - width: 80%; - align-items: center; -} - -.expense-title { - font-size: 1.6rem; - color: var(--gray); -} - -.expense-info { - justify-content: space-between; -} - -.expense-info a { - margin: 0; -} - -.expense-info form.button_to button { - margin: 0; -} - -/* user show */ - -.user-name { - font-size: 2rem; - color: var(--gray); -} - -.user-email { - font-size: 1.6rem; - color: var(--gray); -} - -/* NAVBAR */ - -.navbar { - display: flex; - justify-content: space-around; - width: 100%; -} - -.navbar li a { - color: white; -} - -.single-group p a { - background-color: transparent; - font-size: 1.8rem; - color: var(--gray); -} diff --git a/app/assets/stylesheets/expenses.css b/app/assets/stylesheets/expenses.css new file mode 100644 index 0000000..c126a64 --- /dev/null +++ b/app/assets/stylesheets/expenses.css @@ -0,0 +1,40 @@ +.exp { + width: 96%; + background-color: white; + border-radius: 5px; + flex-wrap: wrap; + margin-top: 0.25rem; + height: 63px; +} + +.exp-name { + width: 50%; + font-size: 21px; + font-weight: 500; +} + +.exp-amount { + width: 25%; + font-size: 22px; + font-weight: 300; +} + +.exp-div { + width: 25%; + height: 90%; + text-align: right; + display: flex; + align-items: center; + justify-content: flex-end; + flex-wrap: wrap; +} + +.exp-div a { + width: 100%; + font-size: large; +} + +.exp-icon { + width: 20%; + margin-right: 2px; +} diff --git a/app/assets/stylesheets/forms.css b/app/assets/stylesheets/forms.css new file mode 100644 index 0000000..9af472d --- /dev/null +++ b/app/assets/stylesheets/forms.css @@ -0,0 +1,88 @@ +form { + margin-top: 0.5rem; + width: 96%; + display: flex; + flex-wrap: wrap; + justify-content: center; +} + +form div, +form.edit_user div, +form.new_user div { + margin: 0.15rem 0; + width: 100%; + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} + +form input[type=number], +form input[type=text], +form input[type=email], +form input[type=password], +form textarea { + width: 99%; + background-color: white; + border: 1px solid #cbcbcb; + height: 45px; + padding-left: 9px; + text-align: left; + font-size: 18px; + font-weight: 200; +} + +form input[type=text], +form input[type=email]::placeholder, +form input[type=password]::placeholder { + text-align: left; + padding-left: 9px; + font-weight: 400; +} + +#user_remember_me { + margin: 0.25rem; +} + +.shared-links { + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} + +.shared-links a { + width: 100%; + text-align: center; + margin-top: 0.5rem; + transition: color 200ms ease-in-out; +} + +.shared-links a:hover { + color: var(--color-main); +} + +.cancel-acc { + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; + width: 100%; +} + +.cancel-acc p { + width: 90%; + text-align: center; + margin-top: 0.5rem; +} + +#category_icon { + font-size: 30px; +} + +form div label { + font-size: 16px; + font-weight: 400; + width: 100%; + text-align: center; +} diff --git a/app/assets/stylesheets/groups.css b/app/assets/stylesheets/groups.css new file mode 100644 index 0000000..55d662d --- /dev/null +++ b/app/assets/stylesheets/groups.css @@ -0,0 +1,22 @@ +#categories a { + width: 96%; + background-color: white; + border-radius: 5px; + flex-wrap: wrap; + margin-top: 0.25rem; + height: 63px; +} + +.cat-icon { + font-size: 36px; +} + +.cat-name { + width: 50%; + font-size: 20px; + font-weight: 300; +} + +.cat-total { + width: 30%; +} diff --git a/app/assets/stylesheets/main.css b/app/assets/stylesheets/main.css new file mode 100644 index 0000000..e6801e1 --- /dev/null +++ b/app/assets/stylesheets/main.css @@ -0,0 +1,77 @@ +.container { + width: 100%; + max-width: 720px; +} + +.flex { + display: flex; + justify-content: center; + align-items: center; + flex-wrap: wrap; +} + +.btn-group { + width: 100%; +} + +.btn-main, +.btn-white { + padding: 0.75rem; + margin-top: 1rem; + background-color: var(--color-main); + width: 90%; + border-radius: 0.18rem; + text-align: center; + text-transform: uppercase; + color: white; + letter-spacing: 1px; + font-weight: 400; + cursor: pointer; + font-size: 18px; + border: none; + transition: all 100ms ease-out; +} + +.btn-white { + background-color: white; + color: var(--color-text); +} + +.btn-main:hover { + background-color: #87aeda; + text-shadow: 0 0 10px black; + opacity: 80%; +} + +.btn-white:hover { + background-color: var(--color-third); + color: white; + text-shadow: 0 0 10px black; + opacity: 80%; +} + +.title { + width: 100%; + text-align: center; + font-size: 20px; + font-weight: 300; + background-color: white; + padding: 0.75rem 0; +} + +.inner-container { + width: 100%; + margin-top: 1rem; +} + +.card { + justify-content: space-between; + align-items: center; + padding: 10px 12px; +} + +.inner-card { + display: flex; + flex-direction: column; + gap: 10px; +} diff --git a/app/assets/stylesheets/navbar.css b/app/assets/stylesheets/navbar.css new file mode 100644 index 0000000..d0b7c43 --- /dev/null +++ b/app/assets/stylesheets/navbar.css @@ -0,0 +1,58 @@ +#navbar { + top: 0; + left: 0; + width: 100%; + height: 69px; + background-color: var(--color-main); + display: flex; + justify-content: center; + align-items: center; +} + +#nav-container { + margin-top: 1rem; + display: flex; + justify-content: center; + align-items: center; + width: 99%; + max-width: 720px; +} + +#navbar-body { + width: 90%; + font-size: 18px; + font-weight: 300; + display: flex; + justify-content: flex-end; + align-items: center; +} + +.navbar-list { + width: 99%; + display: flex; + justify-content: center; + align-items: center; +} + +.nav-item, +.nav-item a { + font-size: 13px; + font-weight: 200; + color: white; + width: 25%; + text-align: center; +} + +.nav-back { + text-align: left; +} + +.nav-title { + width: 50%; + font-size: 18px; + font-weight: 400; +} + +.nav-logout { + text-align: right; +} diff --git a/app/assets/stylesheets/noticealert.css b/app/assets/stylesheets/noticealert.css new file mode 100644 index 0000000..68cd811 --- /dev/null +++ b/app/assets/stylesheets/noticealert.css @@ -0,0 +1,17 @@ +.notice, +.alert { + width: 100%; + min-height: min-content; + background-color: var(--color-third); + color: white; + text-align: center; + font-size: 1rem; + font-weight: 300; + line-height: 2.3rem; + opacity: 90%; + letter-spacing: 1px; +} + +.alert { + background-color: var(--color-second); +} diff --git a/app/assets/stylesheets/splash.css b/app/assets/stylesheets/splash.css new file mode 100644 index 0000000..add9dcc --- /dev/null +++ b/app/assets/stylesheets/splash.css @@ -0,0 +1,14 @@ +.splash-container { + width: 100%; + margin: 25% 0; + display: flex; + align-items: center; + justify-content: center; + flex-wrap: wrap; +} + +.splash-logo { + width: 45%; + height: auto; + margin: 0.81rem; +} diff --git a/app/controllers/expenses_controller.rb b/app/controllers/expenses_controller.rb index f37c025..3916054 100644 --- a/app/controllers/expenses_controller.rb +++ b/app/controllers/expenses_controller.rb @@ -5,7 +5,7 @@ class ExpensesController < ApplicationController # GET /expenses or /expenses.json def index - @expenses = @user.expenses.all.order(created_at: :desc) + @expenses = @group.expenses end # GET /expenses/new @@ -72,6 +72,6 @@ def set_expense # Only allow a list of trusted parameters through. def expense_params - params.require(:expense).permit(:name, :amount, :group_ids) + params.require(:expense).permit(:name, :amount, group_ids: []) end end diff --git a/app/models/ability.rb b/app/models/ability.rb new file mode 100644 index 0000000..5b72fe1 --- /dev/null +++ b/app/models/ability.rb @@ -0,0 +1,10 @@ +class Ability + include CanCan::Ability + + def initialize(current_user) + return unless current_user.present? # additional permissions for logged in users (they can read their own posts) + + can :manage, Group, user: current_user + can :manage, Expense, user: current_user + end +end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 38d95b8..b7c4f64 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,11 +1,14 @@ -

Edit <%= resource_name.to_s.humanize %>

+<% provide(:title, resource_name.to_s.humanize) %> <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> <%= render "devise/shared/error_messages", resource: resource %>
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> + <%= f.text_field :name, autofocus: true, autocomplete: "name", placeholder: "Name" %> +
+ +
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: "Email" %>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> @@ -14,7 +17,7 @@
<%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password, autocomplete: "new-password" %> + <%= f.password_field :password, autocomplete: "new-password", placeholder: "New Password" %> <% if @minimum_password_length %>
<%= @minimum_password_length %> characters minimum @@ -22,22 +25,20 @@
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> + <%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: "New Password Confirmation" %>
- <%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password, autocomplete: "current-password" %> + <%= f.password_field :current_password, autocomplete: "current-password", placeholder: "Current Password" %>
- <%= f.submit "Update" %> + <%= f.submit "Update", class: "btn-main" %>
<% end %> -

Cancel my account

- -

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

- +
+

Cancel my account


+

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), class: "btn-white", data: { confirm: "Are you sure?" }, method: :delete %>

+
<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index e9f7278..28eae5d 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,34 +1,28 @@ + + +<% provide(:title, "SIGN UP") %> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> -
- <%= link_to 'Back', root_path, class: 'go-back' %> -

REGISTER

-
- <%= f.submit "Sign up" %> -
-
<%= render "devise/shared/error_messages", resource: resource %> -
-
-
- <%= f.text_field :name, autofocus: true, autocomplete: "name", placeholder: "Full Name" %> -
-
- <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: "Email" %> -
-
- <%= f.label :password %> - <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) - <% end %>
- <%= f.password_field :password, autocomplete: "new-password", placeholder: "******" %> -
-
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: "******" %> -
-
- <% end %> -

You already have an account?

- <%= render "devise/shared/links" %> -
- + +
+ <%= f.text_field :name, autofocus: true, autocomplete: "name", placeholder: 'Name' %> +
+ +
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: 'Email' %> +
+ +
+ <%= f.password_field :password, autocomplete: "new-password", placeholder: 'Password' %> +
+ +
+ <%= f.password_field :password_confirmation, autocomplete: "new-password", placeholder: 'Password Confirmation' %> +
+ +
+ <%= f.submit "Sign up", class: 'btn-main'%> +
+<% end %> +<%= render "devise/shared/links" %> +<%= link_to "Back", :back, class: "btn-main" %> \ No newline at end of file diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 5e5e040..abf37a2 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,29 +1,26 @@ - <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> -
- <%= link_to 'Back', root_path, class: 'go-back' %> -

LOG IN

-
- <%= f.submit "Log in" %> -
+<% provide(:title, "LOG IN") %> + +<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", placeholder: 'Email' %> +
+ +
+ <%= f.password_field :password, autocomplete: "current-password", placeholder: 'Password' %>
-
-
-
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> -
-
- <%= f.label :password %>
- <%= f.password_field :password, autocomplete: "current-password" %> -
- <% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me %> - <%= f.label :remember_me %> -
- <% end %> + + <% if devise_mapping.rememberable? %> +
+ <%= f.check_box :remember_me %> + <%= f.label :remember_me %>
<% end %> -

Don't you have an account?

- <%= render "devise/shared/links" %> -
+ +
+ <%= f.submit "Log in", class: 'btn-main' %> +
+<% end %> + +<%= render "devise/shared/links" %> + +<%= link_to "Back", :back, class: "btn-main" %> \ No newline at end of file diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb index 96a9412..0e65864 100644 --- a/app/views/devise/shared/_links.html.erb +++ b/app/views/devise/shared/_links.html.erb @@ -1,25 +1,27 @@ -<%- if controller_name != 'sessions' %> - <%= link_to "Log in", new_session_path(resource_name) %>
-<% end %> + diff --git a/app/views/expenses/_expense.html.erb b/app/views/expenses/_expense.html.erb index 4a46edf..63d09dd 100644 --- a/app/views/expenses/_expense.html.erb +++ b/app/views/expenses/_expense.html.erb @@ -1,21 +1,15 @@ -
-
-

- <%= expense.name %> -

-

- <%= number_to_currency(expense.amount) %> -

-
-
-

- <%= expense.created_at.strftime("%e %b %y") %> -

-

- Group: - <%= @group.icon %> -

- <%= link_to "Edit", edit_group_expense_path(@group, expense) %> - <%= button_to "Delete", group_expense_path(@group, expense), method: :delete %> +
+

+ <%= expense.name %> +

+

+ $ + <%= expense.amount %> +

+
+ <%= link_to "โœŽ", edit_group_expense_path(@group, expense) %> + <% expense.groups.each do |group| %> +

<%= group.icon %>

+ <% end %>
diff --git a/app/views/expenses/_form.html.erb b/app/views/expenses/_form.html.erb index 2390128..604f2ba 100644 --- a/app/views/expenses/_form.html.erb +++ b/app/views/expenses/_form.html.erb @@ -1,27 +1,27 @@ <%= form_with(model: [@group, @expense]) do |form| %> - <% if expense.errors.any? %> + <% if @expense.errors.any? %>
-

<%= pluralize(expense.errors.count, "error") %> prohibited this expense from being saved:

+

<%= pluralize(@expense.errors.count, "error") %> prohibited this expense from being saved:

    - <% expense.errors.each do |error| %> + <% @expense.errors.each do |error| %>
  • <%= error.full_message %>
  • <% end %>
<% end %> -
-
- <%= form.text_field :name, autofocus: true, autocomplete: "name", placeholder: "Expense Name" %> -
-
- <%= form.number_field :amount, autofocus: true, autocomplete: "amount", placeholder: "Amount" %> -
-
- <%= form.label :group_id, style: "display: block" %> - <%= form.text_field :group_ids %> -
-
- <%= form.submit %> -
+
+ <%= form.label :name, style: "display: block" %> + <%= form.text_field :name %> +
+
+ <%= form.label :amount, style: "display: block" %> + <%= form.number_field :amount %> +
+
+ <%= form.label :group_id, style: "display: block" %> + <%= form.collection_check_boxes(:group_ids, @user.groups.order( 'name ASC' ), :id, :name) %> +
+
+ <%= form.submit class: "btn-main"%>
<% end %> diff --git a/app/views/expenses/edit.html.erb b/app/views/expenses/edit.html.erb index 75f553e..5a24ae2 100644 --- a/app/views/expenses/edit.html.erb +++ b/app/views/expenses/edit.html.erb @@ -1,8 +1,7 @@ -
-

Editing expense

- <%= render "form", expense: @expense %> -
-
- <%= link_to "Back to Group", group_path(@group) %> -
-
+

Editing expense

+<% if can? :manage, @expense %> + <%= render "form", group: @expense %> +<% else %> +

Not your GROUP. Go Back.

+<% end %> +<%= link_to "Back to Group", group_path(@group), class: "btn-white" %> diff --git a/app/views/expenses/index.html.erb b/app/views/expenses/index.html.erb index f93566d..f74fc19 100644 --- a/app/views/expenses/index.html.erb +++ b/app/views/expenses/index.html.erb @@ -1,13 +1,11 @@ -
-

<%= notice %>

-

Expenses

-
- <% @expenses.each do |expense| %> - <%= render expense %> -

- <%= link_to "Show this expense", group_expense_path(@group, expense) %> -

- <% end %> -
- <%= link_to "New expense", new_group_expense_path %> -
+

<%= notice %>

+

Expenses

+
+ <% @expenses.each do |expense| %> + <%= render expense %> +

+ <%= link_to "Show this expense", group_expense_path(@group, expense) %> +

+ <% end %> +
+<%= link_to "New expense", new_group_expense_path(@group) %> diff --git a/app/views/expenses/new.html.erb b/app/views/expenses/new.html.erb index 57274cf..f2dd217 100644 --- a/app/views/expenses/new.html.erb +++ b/app/views/expenses/new.html.erb @@ -1,8 +1,7 @@ -
-

New expense

+<% provide(:title, "NEW EXPENSE") %> +<% if can? :manage, @expense %> <%= render "form", expense: @expense %> -
-
- <%= link_to "Back to Group", group_path(@group) %> -
-
+<% else %> +

Not your GROUP. Go Back.

+<% end %> +<%= link_to "Back to GROUP", group_path(@group), class: "btn-white" %> diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb index b8a30c8..eb955e3 100644 --- a/app/views/groups/_form.html.erb +++ b/app/views/groups/_form.html.erb @@ -9,15 +9,18 @@
<% end %> -
-
- <%= form.text_field :name, autofocus: true, autocomplete: "name", placeholder: "Group Name" %> -
-
- <%= form.select :icon, [['๐ŸŽฒ'], ['๐Ÿš˜'], ['๐Ÿ›’'], ['๐Ÿ•'], ['๐Ÿ“š'], ['๐ŸŽž๏ธ'], ['๐ŸŽถ'], ['๐ŸŽ'], ['๐Ÿ‘พ'], ['โœ๐Ÿฝ'], ['๐Ÿƒ๐Ÿฝ'], ['โค๏ธ'], ['โญ'], ['๐Ÿถ'], ['๐ŸŒณ'], ['๐ŸŒŽ'], ['๐ŸŒ™'], ['๐Ÿ’ง'], ['โ˜€๏ธ'], ['๐ŸŒน'], ['๐Ÿˆ'], ['๐ŸฅŠ'], ['โœˆ๏ธ'], ['๐Ÿ•๏ธ'], ['๐Ÿšฒ'], ['๐Ÿ”จ'], ['๐Ÿ“†'], ['๐Ÿ“Ž'], ['๐Ÿ”’'], ['๐Ÿ“Œ'], ['โœ‚๏ธ'], ['๐Ÿ•™'], ['๐Ÿงน']] %> -
-
- <%= form.submit %> -
+
+ <%= form.label :name %> + <%= form.text_field :name %> +
+
+ <%= form.label :icon %> + <%= form.select :icon, [['๐ŸŽฒ'], ['๐Ÿš˜'], ['๐Ÿ›’'], ['๐Ÿ•'], ['๐Ÿ“š'], ['๐ŸŽž๏ธ'], ['๐ŸŽถ'], ['๐ŸŽ'], + ['๐Ÿ‘พ'], ['โœ๐Ÿฝ'], ['๐Ÿƒ๐Ÿฝ'], ['โค๏ธ'], ['โญ'], ['๐Ÿถ'], ['๐ŸŒณ'], ['๐ŸŒŽ'], ['๐ŸŒ™'], ['๐Ÿ’ง'], ['โ˜€๏ธ'], ['๐ŸŒน'], + ['๐Ÿˆ'], ['๐ŸฅŠ'], ['โœˆ๏ธ'], ['๐Ÿ•๏ธ'], ['๐Ÿšฒ'], ['๐Ÿ”จ'], ['๐Ÿ“†'], ['๐Ÿ“Ž'], ['๐Ÿ”’'], ['๐Ÿ“Œ'], ['โœ‚๏ธ'], ['๐Ÿ•™'], + ['๐Ÿงณ'], ['โค๏ธ'], ['โšฝ๏ธ'], ['๐ŸŽพ'], ['๐Ÿคฟ'], ['๐ŸŽจ'], ['๐ŸŽณ'], ['๐ŸŽฎ'], ['โ›ฝ๏ธ'], ['๐ŸŸ'], ['๐Ÿ“บ'], ['๐Ÿ›Ž'],] %> +
+
+ <%= form.submit class: "btn-main" %>
<% end %> diff --git a/app/views/groups/_group.html.erb b/app/views/groups/_group.html.erb index ab07eca..93ff99b 100644 --- a/app/views/groups/_group.html.erb +++ b/app/views/groups/_group.html.erb @@ -1,11 +1,13 @@ -
-

- <%= group.icon %> -

-

- <%=link_to group.name, group_path(group) %> -

-

- <%= number_to_currency(group.expenses.sum(:amount)) %> -

-
+<%= link_to group do %> +
+

+ <%= group.icon %> +

+

+ <%= group.name %> +

+

Total: + $ <%= group.expenses.sum(:amount) %> +

+
+<% end %> diff --git a/app/views/groups/edit.html.erb b/app/views/groups/edit.html.erb index 30eb5d7..51eabd6 100644 --- a/app/views/groups/edit.html.erb +++ b/app/views/groups/edit.html.erb @@ -1,9 +1,7 @@ -
-

Editing group

+<% provide(:title, "EDIT GROUP") %> +<% if can? :manage, @group %> <%= render "form", group: @group %> -
-
- <%= link_to "Show this group", @group %> - <%= link_to "Back to groups", groups_path %> -
-
+<% else %> +

Not your group. Go Back.

+<% end %> +<%= link_to "Back to groups", groups_path, class: "btn-white" %> diff --git a/app/views/groups/index.html.erb b/app/views/groups/index.html.erb index 3ac47aa..4db8a66 100644 --- a/app/views/groups/index.html.erb +++ b/app/views/groups/index.html.erb @@ -1,10 +1,11 @@ -
-

<%= notice %>

-

GROUPS

- <%= link_to "New group", new_group_path %> -
- <% @groups.each do |group| %> - <%= render group %> - <% end %> -
-
+<% provide(:title, "GROUPS") %> +

+ <%= @user.name %> + <%= link_to "โœ", edit_user_registration_path %> +

+
+ <% @groups.each do |group| %> + <%= render group %> + <% end %> +
+<%= link_to "New group", new_group_path, class: "btn-main" %> diff --git a/app/views/groups/new.html.erb b/app/views/groups/new.html.erb index 621dfaf..fe178c4 100644 --- a/app/views/groups/new.html.erb +++ b/app/views/groups/new.html.erb @@ -1,8 +1,7 @@ -
-

New group

+<% provide(:title, "NEW GROUP") %> +<% if can? :manage, @group %> <%= render "form", group: @group %> -
-
- <%= link_to "Back to groups", groups_path %> -
-
+<% else %> +

Not your group. Go Back.

+<% end %> +<%= link_to "Back to groups", groups_path, class: "btn-white" %> diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb index 2c011bf..623f4d4 100644 --- a/app/views/groups/show.html.erb +++ b/app/views/groups/show.html.erb @@ -1,12 +1,13 @@ -
-

<%= notice %>

- <%= render @group %> -
- <%= link_to "New expense", new_group_expense_path(@group, @expense), class: "btn-main" %> - <%= link_to "Edit this group", edit_group_path(@group) %> - <%= button_to "Delete this group", @group, method: :delete %> +<% provide(:title, "GROUP") %> +<% if can? :manage, @group %> +
+ <%= render @group %>
-
+
<%= render @expenses %>
-
+ <%= link_to "New expense", new_group_expense_path(@group, @expense), class: "btn-main" %> + <%= link_to "Edit this group", edit_group_path(@group), class: "btn-white" %> +<% else %> +

Not your group. Go Back.

+<% end %> diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb new file mode 100644 index 0000000..7efd9d7 --- /dev/null +++ b/app/views/layouts/_navbar.html.erb @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b661646..5c95648 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,25 +13,13 @@ <%= favicon_link_tag asset_path('favicon.png') %> - <% if user_signed_in?%> - - <%end%> - <% if notice %> -

<%= notice %>

- <% end %> <% if alert %> -

<%= alert %>

- <% end %> - <%= yield %> +
+ <%= render partial: 'layouts/navbar' %> +
+

<%= notice %>

+

<%= alert %>

+ <%= yield %> +
+
diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index 18712f9..0032e01 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -9,15 +9,11 @@
<% end %> -
-
- <%= form.text_field :name, autofocus: true, autocomplete: "name", placeholder: "Full Name" %> -
-
- <%= form.email_field :email, autofocus: true, autocomplete: "email", placeholder: "Email" %> -
-
- <%= form.submit %> -
+
+ <%= form.label :name, style: "display: block" %> + <%= form.text_field :name %> +
+
+ <%= form.submit %>
<% end %> diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index 0acef9d..e69bc79 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -1,10 +1,6 @@
-

+

Name: <%= user.name %>

-

- Email: - <%= user.email %> -

diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index de28b65..644a714 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,9 +1,7 @@ -
-

Editing user

- <%= render "form", user: @user %> -
-
- <%= link_to "Show this user", @user %> - <%= link_to "Back to home", root_path %> -
-
+

Editing user

+<%= render "form", user: @user %> +
+
+ <%= link_to "Show this user", @user %> | + <%= link_to "Back to users", users_path %> +
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index afd759f..6fb7a7f 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1,9 +1,7 @@ -
-

<%= notice %>

- <%= render @user %> -
- <%= link_to "Edit this user", edit_user_path(@user) %> - <%= link_to "Log out", destroy_user_session_path, method: :delete, data: { turbo_method: :delete }%> - <%= button_to "Delete my account", @user, method: :delete %> -
+

<%= notice %>

+<%= render @user %> +
+ <%= link_to "Edit this user", edit_user_path(@user) %> | + <%= link_to "Back to users", users_path %> + <%= button_to "Destroy this user", @user, method: :delete %>
diff --git a/app/views/users/splash.html.erb b/app/views/users/splash.html.erb index 70cf615..a61159c 100644 --- a/app/views/users/splash.html.erb +++ b/app/views/users/splash.html.erb @@ -1,8 +1,8 @@ -
+<% provide(:title, "WELCOME") %> +
<%= image_tag('logo.png', class: 'splash-logo') %> - <% unless user_signed_in? %> -
- <%= link_to "LOG IN", new_user_session_path, :class => 'login-btn' %> - <%= link_to "SIGN UP", new_user_registration_path, :class => 'signup-btn' %> - <% end %> -
+
+ <%= link_to 'Log In', new_user_session_path, class: 'btn-main' %> + <%= link_to 'Sign Up', new_user_registration_path, class: 'btn-white' %> +
+
diff --git a/config/environments/development.rb b/config/environments/development.rb index cc5a9da..63c49e4 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,14 +1,7 @@ require "active_support/core_ext/integer/time" Rails.application.configure do - config.after_initialize do - Bullet.enable = true - Bullet.alert = true - Bullet.bullet_logger = true - Bullet.console = true - Bullet.rails_logger = true - Bullet.add_footer = true - end + # Settings specified here will take precedence over those in config/application.rb. diff --git a/spec/helpers/expenses_helper_spec.rb b/spec/helpers/expenses_helper_spec.rb deleted file mode 100644 index 015ef7f..0000000 --- a/spec/helpers/expenses_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the ExpensesHelper. For example: -# -# describe ExpensesHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe ExpensesHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb deleted file mode 100644 index a83fa46..0000000 --- a/spec/helpers/groups_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the GroupsHelper. For example: -# -# describe GroupsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe GroupsHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb deleted file mode 100644 index b2e3444..0000000 --- a/spec/helpers/users_helper_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the UsersHelper. For example: -# -# describe UsersHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end -RSpec.describe UsersHelper, type: :helper do - pending "add some examples to (or delete) #{__FILE__}" -end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 682cf46..983a4d2 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2,7 +2,7 @@ RSpec.describe User, type: :model do subject do - User.new(name: 'Tommy') + User.new(name: 'Tommy', email: 'tommy@email.com', password: '123456') end before(:example) { subject.save } diff --git a/spec/requests/expenses_spec.rb b/spec/requests/expenses_spec.rb deleted file mode 100644 index 3a20287..0000000 --- a/spec/requests/expenses_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe '/expenses', type: :request do - # This should return the minimal set of attributes required to create a valid - # Expense. As you add validations to Expense, be sure to - # adjust the attributes here as well. - let(:valid_attributes) do - skip('Add a hash of attributes valid for your model') - end - - let(:invalid_attributes) do - skip('Add a hash of attributes invalid for your model') - end - - describe 'GET /index' do - it 'renders a successful response' do - Expense.create! valid_attributes - get expenses_url - expect(response).to be_successful - end - end - - describe 'GET /show' do - it 'renders a successful response' do - expense = Expense.create! valid_attributes - get expense_url(expense) - expect(response).to be_successful - end - end - - describe 'GET /new' do - it 'renders a successful response' do - get new_expense_url - expect(response).to be_successful - end - end - - describe 'GET /edit' do - it 'renders a successful response' do - expense = Expense.create! valid_attributes - get edit_expense_url(expense) - expect(response).to be_successful - end - end - - describe 'POST /create' do - context 'with valid parameters' do - it 'creates a new Expense' do - expect do - post expenses_url, params: { expense: valid_attributes } - end.to change(Expense, :count).by(1) - end - - it 'redirects to the created expense' do - post expenses_url, params: { expense: valid_attributes } - expect(response).to redirect_to(expense_url(Expense.last)) - end - end - - context 'with invalid parameters' do - it 'does not create a new Expense' do - expect do - post expenses_url, params: { expense: invalid_attributes } - end.to change(Expense, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post expenses_url, params: { expense: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'PATCH /update' do - context 'with valid parameters' do - let(:new_attributes) do - skip('Add a hash of attributes valid for your model') - end - - it 'updates the requested expense' do - expense = Expense.create! valid_attributes - patch expense_url(expense), params: { expense: new_attributes } - expense.reload - skip('Add assertions for updated state') - end - - it 'redirects to the expense' do - expense = Expense.create! valid_attributes - patch expense_url(expense), params: { expense: new_attributes } - expense.reload - expect(response).to redirect_to(expense_url(expense)) - end - end - - context 'with invalid parameters' do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - expense = Expense.create! valid_attributes - patch expense_url(expense), params: { expense: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'DELETE /destroy' do - it 'destroys the requested expense' do - expense = Expense.create! valid_attributes - expect do - delete expense_url(expense) - end.to change(Expense, :count).by(-1) - end - - it 'redirects to the expenses list' do - expense = Expense.create! valid_attributes - delete expense_url(expense) - expect(response).to redirect_to(expenses_url) - end - end -end diff --git a/spec/requests/groups_spec.rb b/spec/requests/groups_spec.rb deleted file mode 100644 index 450de33..0000000 --- a/spec/requests/groups_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe '/groups', type: :request do - # This should return the minimal set of attributes required to create a valid - # Group. As you add validations to Group, be sure to - # adjust the attributes here as well. - let(:valid_attributes) do - skip('Add a hash of attributes valid for your model') - end - - let(:invalid_attributes) do - skip('Add a hash of attributes invalid for your model') - end - - describe 'GET /index' do - it 'renders a successful response' do - Group.create! valid_attributes - get groups_url - expect(response).to be_successful - end - end - - describe 'GET /show' do - it 'renders a successful response' do - group = Group.create! valid_attributes - get group_url(group) - expect(response).to be_successful - end - end - - describe 'GET /new' do - it 'renders a successful response' do - get new_group_url - expect(response).to be_successful - end - end - - describe 'GET /edit' do - it 'renders a successful response' do - group = Group.create! valid_attributes - get edit_group_url(group) - expect(response).to be_successful - end - end - - describe 'POST /create' do - context 'with valid parameters' do - it 'creates a new Group' do - expect do - post groups_url, params: { group: valid_attributes } - end.to change(Group, :count).by(1) - end - - it 'redirects to the created group' do - post groups_url, params: { group: valid_attributes } - expect(response).to redirect_to(group_url(Group.last)) - end - end - - context 'with invalid parameters' do - it 'does not create a new Group' do - expect do - post groups_url, params: { group: invalid_attributes } - end.to change(Group, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post groups_url, params: { group: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'PATCH /update' do - context 'with valid parameters' do - let(:new_attributes) do - skip('Add a hash of attributes valid for your model') - end - - it 'updates the requested group' do - group = Group.create! valid_attributes - patch group_url(group), params: { group: new_attributes } - group.reload - skip('Add assertions for updated state') - end - - it 'redirects to the group' do - group = Group.create! valid_attributes - patch group_url(group), params: { group: new_attributes } - group.reload - expect(response).to redirect_to(group_url(group)) - end - end - - context 'with invalid parameters' do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - group = Group.create! valid_attributes - patch group_url(group), params: { group: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'DELETE /destroy' do - it 'destroys the requested group' do - group = Group.create! valid_attributes - expect do - delete group_url(group) - end.to change(Group, :count).by(-1) - end - - it 'redirects to the groups list' do - group = Group.create! valid_attributes - delete group_url(group) - expect(response).to redirect_to(groups_url) - end - end -end diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb deleted file mode 100644 index 701c7d3..0000000 --- a/spec/requests/users_spec.rb +++ /dev/null @@ -1,130 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to test the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. - -RSpec.describe '/users', type: :request do - # This should return the minimal set of attributes required to create a valid - # User. As you add validations to User, be sure to - # adjust the attributes here as well. - let(:valid_attributes) do - skip('Add a hash of attributes valid for your model') - end - - let(:invalid_attributes) do - skip('Add a hash of attributes invalid for your model') - end - - describe 'GET /index' do - it 'renders a successful response' do - User.create! valid_attributes - get users_url - expect(response).to be_successful - end - end - - describe 'GET /show' do - it 'renders a successful response' do - user = User.create! valid_attributes - get user_url(user) - expect(response).to be_successful - end - end - - describe 'GET /new' do - it 'renders a successful response' do - get new_user_url - expect(response).to be_successful - end - end - - describe 'GET /edit' do - it 'renders a successful response' do - user = User.create! valid_attributes - get edit_user_url(user) - expect(response).to be_successful - end - end - - describe 'POST /create' do - context 'with valid parameters' do - it 'creates a new User' do - expect do - post users_url, params: { user: valid_attributes } - end.to change(User, :count).by(1) - end - - it 'redirects to the created user' do - post users_url, params: { user: valid_attributes } - expect(response).to redirect_to(user_url(User.last)) - end - end - - context 'with invalid parameters' do - it 'does not create a new User' do - expect do - post users_url, params: { user: invalid_attributes } - end.to change(User, :count).by(0) - end - - it "renders a response with 422 status (i.e. to display the 'new' template)" do - post users_url, params: { user: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'PATCH /update' do - context 'with valid parameters' do - let(:new_attributes) do - skip('Add a hash of attributes valid for your model') - end - - it 'updates the requested user' do - user = User.create! valid_attributes - patch user_url(user), params: { user: new_attributes } - user.reload - skip('Add assertions for updated state') - end - - it 'redirects to the user' do - user = User.create! valid_attributes - patch user_url(user), params: { user: new_attributes } - user.reload - expect(response).to redirect_to(user_url(user)) - end - end - - context 'with invalid parameters' do - it "renders a response with 422 status (i.e. to display the 'edit' template)" do - user = User.create! valid_attributes - patch user_url(user), params: { user: invalid_attributes } - expect(response).to have_http_status(:unprocessable_entity) - end - end - end - - describe 'DELETE /destroy' do - it 'destroys the requested user' do - user = User.create! valid_attributes - expect do - delete user_url(user) - end.to change(User, :count).by(-1) - end - - it 'redirects to the users list' do - user = User.create! valid_attributes - delete user_url(user) - expect(response).to redirect_to(users_url) - end - end -end diff --git a/spec/routing/expenses_routing_spec.rb b/spec/routing/expenses_routing_spec.rb deleted file mode 100644 index 9a438cb..0000000 --- a/spec/routing/expenses_routing_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'rails_helper' - -RSpec.describe ExpensesController, type: :routing do - describe 'routing' do - it 'routes to #index' do - expect(get: '/expenses').to route_to('expenses#index') - end - - it 'routes to #new' do - expect(get: '/expenses/new').to route_to('expenses#new') - end - - it 'routes to #show' do - expect(get: '/expenses/1').to route_to('expenses#show', id: '1') - end - - it 'routes to #edit' do - expect(get: '/expenses/1/edit').to route_to('expenses#edit', id: '1') - end - - it 'routes to #create' do - expect(post: '/expenses').to route_to('expenses#create') - end - - it 'routes to #update via PUT' do - expect(put: '/expenses/1').to route_to('expenses#update', id: '1') - end - - it 'routes to #update via PATCH' do - expect(patch: '/expenses/1').to route_to('expenses#update', id: '1') - end - - it 'routes to #destroy' do - expect(delete: '/expenses/1').to route_to('expenses#destroy', id: '1') - end - end -end diff --git a/spec/routing/groups_routing_spec.rb b/spec/routing/groups_routing_spec.rb deleted file mode 100644 index d469dba..0000000 --- a/spec/routing/groups_routing_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'rails_helper' - -RSpec.describe GroupsController, type: :routing do - describe 'routing' do - it 'routes to #index' do - expect(get: '/groups').to route_to('groups#index') - end - - it 'routes to #new' do - expect(get: '/groups/new').to route_to('groups#new') - end - - it 'routes to #show' do - expect(get: '/groups/1').to route_to('groups#show', id: '1') - end - - it 'routes to #edit' do - expect(get: '/groups/1/edit').to route_to('groups#edit', id: '1') - end - - it 'routes to #create' do - expect(post: '/groups').to route_to('groups#create') - end - - it 'routes to #update via PUT' do - expect(put: '/groups/1').to route_to('groups#update', id: '1') - end - - it 'routes to #update via PATCH' do - expect(patch: '/groups/1').to route_to('groups#update', id: '1') - end - - it 'routes to #destroy' do - expect(delete: '/groups/1').to route_to('groups#destroy', id: '1') - end - end -end diff --git a/spec/routing/users_routing_spec.rb b/spec/routing/users_routing_spec.rb deleted file mode 100644 index 7933520..0000000 --- a/spec/routing/users_routing_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'rails_helper' - -RSpec.describe UsersController, type: :routing do - describe 'routing' do - it 'routes to #index' do - expect(get: '/users').to route_to('users#index') - end - - it 'routes to #new' do - expect(get: '/users/new').to route_to('users#new') - end - - it 'routes to #show' do - expect(get: '/users/1').to route_to('users#show', id: '1') - end - - it 'routes to #edit' do - expect(get: '/users/1/edit').to route_to('users#edit', id: '1') - end - - it 'routes to #create' do - expect(post: '/users').to route_to('users#create') - end - - it 'routes to #update via PUT' do - expect(put: '/users/1').to route_to('users#update', id: '1') - end - - it 'routes to #update via PATCH' do - expect(patch: '/users/1').to route_to('users#update', id: '1') - end - - it 'routes to #destroy' do - expect(delete: '/users/1').to route_to('users#destroy', id: '1') - end - end -end diff --git a/spec/views/expenses/edit.html.erb_spec.rb b/spec/views/expenses/edit.html.erb_spec.rb deleted file mode 100644 index ac138cb..0000000 --- a/spec/views/expenses/edit.html.erb_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'expenses/edit', type: :view do - let(:expense) do - Expense.create!( - name: 'MyString', - amount: 1.5, - group: nil - ) - end - - before(:each) do - assign(:expense, expense) - end - - it 'renders the edit expense form' do - render - - assert_select 'form[action=?][method=?]', expense_path(expense), 'post' do - assert_select 'input[name=?]', 'expense[name]' - - assert_select 'input[name=?]', 'expense[amount]' - - assert_select 'input[name=?]', 'expense[group_id]' - end - end -end diff --git a/spec/views/expenses/index.html.erb_spec.rb b/spec/views/expenses/index.html.erb_spec.rb deleted file mode 100644 index 98f4a41..0000000 --- a/spec/views/expenses/index.html.erb_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'expenses/index', type: :view do - before(:each) do - assign(:expenses, [ - Expense.create!( - name: 'Name', - amount: 2.5, - group: nil - ), - Expense.create!( - name: 'Name', - amount: 2.5, - group: nil - ) - ]) - end - - it 'renders a list of expenses' do - render - cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td' - assert_select cell_selector, text: Regexp.new('Name'.to_s), count: 2 - assert_select cell_selector, text: Regexp.new(2.5.to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/expenses/new.html.erb_spec.rb b/spec/views/expenses/new.html.erb_spec.rb deleted file mode 100644 index e98e12e..0000000 --- a/spec/views/expenses/new.html.erb_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'expenses/new', type: :view do - before(:each) do - assign(:expense, Expense.new( - name: 'MyString', - amount: 1.5, - group: nil - )) - end - - it 'renders new expense form' do - render - - assert_select 'form[action=?][method=?]', expenses_path, 'post' do - assert_select 'input[name=?]', 'expense[name]' - - assert_select 'input[name=?]', 'expense[amount]' - - assert_select 'input[name=?]', 'expense[group_id]' - end - end -end diff --git a/spec/views/expenses/show.html.erb_spec.rb b/spec/views/expenses/show.html.erb_spec.rb deleted file mode 100644 index 41dafdc..0000000 --- a/spec/views/expenses/show.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'expenses/show', type: :view do - before(:each) do - assign(:expense, Expense.create!( - name: 'Name', - amount: 2.5, - group: nil - )) - end - - it 'renders attributes in

' do - render - expect(rendered).to match(/Name/) - expect(rendered).to match(/2.5/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/groups/edit.html.erb_spec.rb b/spec/views/groups/edit.html.erb_spec.rb deleted file mode 100644 index 855edb5..0000000 --- a/spec/views/groups/edit.html.erb_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'groups/edit', type: :view do - let(:group) do - Group.create!( - name: 'MyString', - icon: 'MyString', - user: nil - ) - end - - before(:each) do - assign(:group, group) - end - - it 'renders the edit group form' do - render - - assert_select 'form[action=?][method=?]', group_path(group), 'post' do - assert_select 'input[name=?]', 'group[name]' - - assert_select 'input[name=?]', 'group[icon]' - - assert_select 'input[name=?]', 'group[user_id]' - end - end -end diff --git a/spec/views/groups/index.html.erb_spec.rb b/spec/views/groups/index.html.erb_spec.rb deleted file mode 100644 index e1e0cdb..0000000 --- a/spec/views/groups/index.html.erb_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'groups/index', type: :view do - before(:each) do - assign(:groups, [ - Group.create!( - name: 'Name', - icon: 'Icon', - user: nil - ), - Group.create!( - name: 'Name', - icon: 'Icon', - user: nil - ) - ]) - end - - it 'renders a list of groups' do - render - cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td' - assert_select cell_selector, text: Regexp.new('Name'.to_s), count: 2 - assert_select cell_selector, text: Regexp.new('Icon'.to_s), count: 2 - assert_select cell_selector, text: Regexp.new(nil.to_s), count: 2 - end -end diff --git a/spec/views/groups/new.html.erb_spec.rb b/spec/views/groups/new.html.erb_spec.rb deleted file mode 100644 index 231487c..0000000 --- a/spec/views/groups/new.html.erb_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'groups/new', type: :view do - before(:each) do - assign(:group, Group.new( - name: 'MyString', - icon: 'MyString', - user: nil - )) - end - - it 'renders new group form' do - render - - assert_select 'form[action=?][method=?]', groups_path, 'post' do - assert_select 'input[name=?]', 'group[name]' - - assert_select 'input[name=?]', 'group[icon]' - - assert_select 'input[name=?]', 'group[user_id]' - end - end -end diff --git a/spec/views/groups/show.html.erb_spec.rb b/spec/views/groups/show.html.erb_spec.rb deleted file mode 100644 index 7c12ee6..0000000 --- a/spec/views/groups/show.html.erb_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'groups/show', type: :view do - before(:each) do - assign(:group, Group.create!( - name: 'Name', - icon: 'Icon', - user: nil - )) - end - - it 'renders attributes in

' do - render - expect(rendered).to match(/Name/) - expect(rendered).to match(/Icon/) - expect(rendered).to match(//) - end -end diff --git a/spec/views/users/edit.html.erb_spec.rb b/spec/views/users/edit.html.erb_spec.rb deleted file mode 100644 index da88d16..0000000 --- a/spec/views/users/edit.html.erb_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/edit', type: :view do - let(:user) do - User.create!( - name: 'MyString' - ) - end - - before(:each) do - assign(:user, user) - end - - it 'renders the edit user form' do - render - - assert_select 'form[action=?][method=?]', user_path(user), 'post' do - assert_select 'input[name=?]', 'user[name]' - end - end -end diff --git a/spec/views/users/index.html.erb_spec.rb b/spec/views/users/index.html.erb_spec.rb deleted file mode 100644 index 4f951b8..0000000 --- a/spec/views/users/index.html.erb_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/index', type: :view do - before(:each) do - assign(:users, [ - User.create!( - name: 'Name' - ), - User.create!( - name: 'Name' - ) - ]) - end - - it 'renders a list of users' do - render - cell_selector = Rails::VERSION::STRING >= '7' ? 'div>p' : 'tr>td' - assert_select cell_selector, text: Regexp.new('Name'.to_s), count: 2 - end -end diff --git a/spec/views/users/new.html.erb_spec.rb b/spec/views/users/new.html.erb_spec.rb deleted file mode 100644 index 79751dc..0000000 --- a/spec/views/users/new.html.erb_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/new', type: :view do - before(:each) do - assign(:user, User.new( - name: 'MyString' - )) - end - - it 'renders new user form' do - render - - assert_select 'form[action=?][method=?]', users_path, 'post' do - assert_select 'input[name=?]', 'user[name]' - end - end -end diff --git a/spec/views/users/show.html.erb_spec.rb b/spec/views/users/show.html.erb_spec.rb deleted file mode 100644 index e44cd05..0000000 --- a/spec/views/users/show.html.erb_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'users/show', type: :view do - before(:each) do - assign(:user, User.create!( - name: 'Name' - )) - end - - it 'renders attributes in

' do - render - expect(rendered).to match(/Name/) - end -end