mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-02-28 16:53:23 -05:00
Added delete time entry feature spec
This commit is contained in:
parent
5e0d678ea1
commit
ca3026e7c5
@ -22,6 +22,6 @@ class TimeEntry < ActsAsLoggable::Log
|
|||||||
end
|
end
|
||||||
|
|
||||||
def type
|
def type
|
||||||
log_action.action
|
log_action.try(:action)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,15 +65,14 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def total_credits_spent
|
def total_credits_spent
|
||||||
log_action = ::ActsAsLoggable::TransactionAction.find_by_action("TIME")
|
log_action_id = 1 #TIME
|
||||||
transaction_logs.
|
transaction_logs.
|
||||||
where( "log_action_id = ? AND log_action_type = ?",
|
where( "log_action_id = ? AND log_action_type = ?",
|
||||||
log_action.id, log_action.class.to_s).
|
log_action_id, ::ActsAsLoggable::TransactionAction.to_s).
|
||||||
sum{ |r| r.description.to_i }.round(2)
|
sum{ |r| r.description.to_i }.round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_earned_credits
|
def total_earned_credits
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
|
||||||
volunteer_id = 1
|
volunteer_id = 1
|
||||||
staff_id = 3
|
staff_id = 3
|
||||||
|
|
||||||
@ -98,20 +97,20 @@ class User < ActiveRecord::Base
|
|||||||
ORDER BY logs.created_at, conversion.created_at DESC",
|
ORDER BY logs.created_at, conversion.created_at DESC",
|
||||||
{id: self.id,
|
{id: self.id,
|
||||||
credit_actions: [volunteer_id, staff_id],
|
credit_actions: [volunteer_id, staff_id],
|
||||||
log_action_type: log_action.class.to_s}]).
|
log_action_type: ::ActsAsLoggable::UserAction.to_s}]).
|
||||||
sum{ |l| ((l.end_date - l.start_date)/3600) * l.conversion.to_i}.round(2)
|
sum{ |l| ((l.end_date - l.start_date)/3600) * l.conversion.to_i}.round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def total_hours
|
def total_hours
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
log_action_id = 4 #CHECKIN
|
||||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
|
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s).sum { |l| (l.end_date - l.start_date)/3600 }.round(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
def current_month_hours
|
def current_month_hours
|
||||||
log_action = ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")
|
log_action_id = 4 #CHECKIN
|
||||||
#TODO need to prevent users from saving logs across months, force to create a new log if crossing month
|
#TODO need to prevent users from saving logs across months, force to create a new log if crossing month
|
||||||
current_month_range = (Time.now.beginning_of_month..Time.now.end_of_month)
|
current_month_range = (Time.now.beginning_of_month..Time.now.end_of_month)
|
||||||
logs.where("log_action_id != ? AND log_action_type = ?", log_action.id, log_action.class.to_s)
|
logs.where("log_action_id != ? AND log_action_type = ?", log_action_id, ::ActsAsLoggable::UserAction.to_s)
|
||||||
.where( :start_date => current_month_range)
|
.where( :start_date => current_month_range)
|
||||||
.where( :end_date => current_month_range)
|
.where( :end_date => current_month_range)
|
||||||
.sum { |l| (l.end_date - l.start_date)/3600 }
|
.sum { |l| (l.end_date - l.start_date)/3600 }
|
||||||
|
23
spec/features/time_entries/index_spec.rb
Normal file
23
spec/features/time_entries/index_spec.rb
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
require "spec_helper"
|
||||||
|
|
||||||
|
feature "TimeEntries" do
|
||||||
|
let!(:user){ FactoryGirl.create(:user) }
|
||||||
|
let!(:entry){ FactoryGirl.create(:time_entry, loggable_id: user.id) }
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
visit new_user_session_path
|
||||||
|
fill_in "user_username", with: user.username
|
||||||
|
fill_in "user_password", with: user.password
|
||||||
|
click_button "Sign in"
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "User deletes a time entry", js: true do
|
||||||
|
visit time_entries_path
|
||||||
|
puts TimeEntry.where(loggable_id: user.id).inspect
|
||||||
|
save_screenshot("/tmp/testingpoop.png")
|
||||||
|
find('button.work_entry-delete-btn').trigger('click')
|
||||||
|
click_button "Delete"
|
||||||
|
expect(page).to have_text("Your Timesheet")
|
||||||
|
expect(TimeEntry.count).to eql 0
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user