New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to perform other expense operations #10

Merged
merged 41 commits into from Oct 24, 2015

Conversation

Projects
None yet
2 participants
@boddhisattva
Owner

boddhisattva commented Oct 23, 2015

No description provided.

boddhisattva added some commits Oct 23, 2015

Creates an expense in an idiomatically correct way
- A new expense is created based on the association it has with a user
Allows a user to see a list of expenses via datatables
For loading all a user’s expenses we use the datatables gem via
https://rails-assets.org/ because they help one better manage front end
related dependencies.

As part of installing the rails assets  datatables gem,
rails-assets-jquery gem also gets installed. With this we remove the
rails-query gem(to avoid having two duplicate gems serve the same
purpose) and we also add the unobtrusive scripting adapter for jQuery
namely jquery-ujs via rails-assets.org

Other important points to note as part of this commit include:

- A user logged into the system would see their expenses in the order of
the most recently made expense(based on the actual expense date) and subsequent expenses that come thereafter
Adds an FAQ page to the app along with a few miscellaneous fixes
Misc fixes include
- A fix to the contact page related spec description
- A name related fix in the footer wrt who has worked on the app
Redirects a successful user signup to app home page
Fixes failing specs with this change
Displays user name as part of the welcome message
This message is also displayed when a user has no expenses
Removes index display of user expenses
This change is added because user expenses are now displayed on app
home page. The index display of expenses is thereby no longer used.
Show outdated Hide outdated app/models/user.rb
Show outdated Hide outdated app/models/user.rb
params.require(:expense).permit(:name, :cost, :date)
end
def get_user_expenses

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Inconsistent indentation detected.

@houndci-bot

houndci-bot Oct 23, 2015

Inconsistent indentation detected.

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Inconsistent indentation detected.

@houndci-bot

houndci-bot Oct 23, 2015

Inconsistent indentation detected.

@@ -3,4 +3,12 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
include SessionsHelper
private

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Keep a blank line before and after private.

@houndci-bot

houndci-bot Oct 23, 2015

Keep a blank line before and after private.

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Keep a blank line before and after private.

@houndci-bot

houndci-bot Oct 23, 2015

Keep a blank line before and after private.

@@ -0,0 +1,3 @@
#welcome_message {

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector welcome_message should be written in lowercase with hyphens

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector welcome_message should be written in lowercase with hyphens

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector welcome_message should be written in lowercase with hyphens

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector welcome_message should be written in lowercase with hyphens

@@ -0,0 +1,7 @@
#create_expense_link {

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector create_expense_link should be written in lowercase with hyphens

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector create_expense_link should be written in lowercase with hyphens

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector create_expense_link should be written in lowercase with hyphens

@houndci-bot

houndci-bot Oct 23, 2015

Avoid using id selectors
Selector create_expense_link should be written in lowercase with hyphens

private
def authenticate_user

This comment has been minimized.

@houndci-bot

houndci-bot Oct 23, 2015

Inconsistent indentation detected.

@houndci-bot

houndci-bot Oct 23, 2015

Inconsistent indentation detected.

boddhisattva added some commits Oct 23, 2015

Sorts the correct datatable column
The datatable columns start with an index 0 and since we’re sorting the
expenses based on the criteria that the most recently made
expense(i.e., based on actual expense date) should show up first, hence
this change is added to the appropriate column.
Disables datatables sorting for 'edit' and 'delete' columns
Datatables provides sorting on all columns by default. Sorting wrt the
‘edit’ and ‘delete’ columns is of no use when displaying expenses and
they’re hence removed.
Ensures that redirection is done at URI level
This is basically because it’s an HTTP specification. One can read more
on this on the link -
https://viget.com/extend/rails-named-routes-path-vs-url

boddhisattva added some commits Oct 24, 2015

Adds a DB index to render the app homepage faster
User expenses are displayed on app homepage. As the number of expenses
grow in number this multiple key index(based on the user_id and the
created_at) would help fetch that data from the table faster. For more
details, one could consider referring the link -
http://stackoverflow.com/questions/4445507/rails-created-at-when-user-fo
r-ordering-should-you-add-an-index-to-the-table
Tests user association of an expense
This test checks if the user association of an expense returns the
correct user
Adds failing specs to check for an invalid expense name
An expense name can be invalid if it is ‘nil’ or if it is an empty
string. Both these use cases are addressed in this commit.
Fixes failing spec wrt user sign in
Wrt an earlier commit, a user sign in redirects to the application home
page in which user name is not a title. Hence appropriate changes are
made here.
Uses scopes to retrieve most recent user expenses
The advantage with using scopes is that they’re chainable. Also for one
liners we needn’t really have to go in for a class method. This commit
also makes the below changes -

- Changes the method name to make it more expressive
- Appropriate changes are introduced in other places that used the
original class method
Tests that expenses feed is displayed in a particular order
The user expenses feed is displayed on the home page in the order of
the most recent first. This spec ensures that this  order is maintained.
margin-top: 36px;
}
#expenses_page_heading {

This comment has been minimized.

@houndci-bot

houndci-bot Oct 24, 2015

Avoid using id selectors
Selector expenses_page_heading should be written in lowercase with hyphens

@houndci-bot

houndci-bot Oct 24, 2015

Avoid using id selectors
Selector expenses_page_heading should be written in lowercase with hyphens

boddhisattva added some commits Oct 24, 2015

Uses "today's" date with time zone in mind
People across the globe are in different time zones, it’s a nice thing
that hound pointed to refer to a date in the context of these time
zones in order to avoid unexpected behavior in the future.
Adds missing spacing between curly braces
More spacing between the curly braces ensures better readability. Hence
this is added.

boddhisattva added a commit that referenced this pull request Oct 24, 2015

Merge pull request #10 from boddhisattva/10-other-expense-related-ope…
…rations

Add ability to perform other expense operations

@boddhisattva boddhisattva merged commit 94aa699 into master Oct 24, 2015

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
hound 11 violations found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment