Skip to content

Commit 8a0bab7

Browse files
committed
cleaning up spec suite a bit. lots in here that isn't needed and/or has changed
1 parent 1528491 commit 8a0bab7

20 files changed

+69
-287
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ group :test do
4949
gem 'factory_girl_rails'
5050
gem 'mocha', require: false
5151
gem 'nokogiri'
52+
gem 'timecop'
5253
end
5354

5455
group :production do

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ GEM
224224
rack (>= 1.0.0)
225225
thor (0.19.1)
226226
tilt (1.4.1)
227+
timecop (0.7.1)
227228
treetop (1.4.15)
228229
polyglot
229230
polyglot (>= 0.3.1)
@@ -276,5 +277,6 @@ DEPENDENCIES
276277
sqlite3
277278
taps
278279
thin
280+
timecop
279281
uglifier (>= 1.0)
280282
unicorn

app/controllers/application_controller.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
66

77
before_filter :require_current_user, :require_current_company, :set_mobile_view
88

9-
protected
9+
protected
1010

1111
def find_target
1212
return unless %w(projects users clients).include? controller_name
@@ -33,7 +33,7 @@ def current_user
3333
end
3434
helper_method :current_user
3535

36-
def require_current_user
36+
def require_current_user
3737
unless current_user.present?
3838
if request.get? && !request.xhr?
3939
cookies[:original_request] = {value: Marshal.dump(request.path_parameters), expires: 2.minutes.from_now}
@@ -52,6 +52,8 @@ def set_mobile_view
5252
session[:mobile_view] = params[:mobile_view] == "true"
5353
set_mobile_format
5454
end
55+
56+
true
5557
end
5658

5759
end

app/controllers/clients_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class ClientsController < ApplicationController
22
respond_to :json
33

4-
before_filter only: [:show, :edit, :update, :destroy] do |c|
4+
before_filter only: [:show, :edit, :update, :destroy] do |c|
55
c.find_target
66
end
77

app/mailers/registration_mailer.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@ class RegistrationMailer < ActionMailer::Base
22

33
def registration_notification(user, company)
44
@registration_info = OpenStruct.new(:first_name => user.first_name, :last_name => user.last_name, :company_name => company.name, :email_address => user.email)
5-
mail :to => User.where(:first_name => "Juhan", :last_name => "Sonin").first.email, :from => "[email protected]", :subject => "Someone has registered a StaffPlan account"
5+
6+
if Rails.env.production?
7+
mail :to => User.where(:first_name => "Juhan", :last_name => "Sonin").first.email, :from => "[email protected]", :subject => "Someone has registered a StaffPlan account"
8+
end
69
end
710

811
def add_staff_notification(user, company)
912
@registration_info = OpenStruct.new(:first_name => user.first_name, :last_name => user.last_name, :company_name => company.name, :email_address => user.email)
10-
mail :to => User.where(:first_name => "Juhan", :last_name => "Sonin").first.email, :from => "[email protected]", :subject => "A new StaffPlan account was just created"
13+
14+
if Rails.env.production?
15+
mail :to => User.where(:first_name => "Juhan", :last_name => "Sonin").first.email, :from => "[email protected]", :subject => "A new StaffPlan account was just created"
16+
end
1117
end
1218

1319
def registration_confirmation user
@@ -17,7 +23,7 @@ def registration_confirmation user
1723

1824
def invitation(user, inviting_user)
1925
@user = user
20-
@admin = inviting_user
26+
@admin = inviting_user
2127
mail to: @user.email, from: "[email protected]", subject: "You're invited to join our project planning and collaboration system"
2228
end
2329

app/models/client.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class Client < ActiveRecord::Base
2-
include StaffPlan::AuditMethods
32
has_paper_trail
43

54
DEFAULT_CLIENT_NAME = "N/A"
@@ -12,8 +11,6 @@ class Client < ActiveRecord::Base
1211

1312
default_scope(order: "name ASC")
1413

15-
after_update :update_originator_timestamp
16-
1714
def staff_plan_json
1815
Jbuilder.encode do |json|
1916
json.(self, :id, :name, :active)

app/models/company.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class Company < ActiveRecord::Base
2-
include StaffPlan::AuditMethods
32
has_paper_trail
43
attr_accessible :name
54

@@ -13,11 +12,9 @@ class Company < ActiveRecord::Base
1312
validates_presence_of :name
1413
validates_uniqueness_of :name
1514

16-
after_update :update_originator_timestamp
17-
1815
# Goes as follows:
1916
# We're deleting a company. Before that happens, we'll take all that company's users
20-
# and set their current_company_id to any other company they're a member of, or to
17+
# and set their current_company_id to any other company they're a member of, or to
2118
# nil if they don't have any left beyond the one we're deleting
2219
before_destroy do |record|
2320
record.users.where(current_company_id: record.id).all.each do |user|

app/models/project.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
class Project < ActiveRecord::Base
2-
include StaffPlan::AuditMethods
32
has_paper_trail
43

54
attr_accessible :name, :active, :payment_frequency, :cost, :client
@@ -12,8 +11,7 @@ class Project < ActiveRecord::Base
1211
has_many :users, through: :assignments
1312

1413
before_save :check_cost
15-
after_update :update_originator_timestamp
16-
14+
1715
validates_presence_of :name, :client
1816
validates_uniqueness_of :name, case_sensitive: false, scope: :client_id
1917

app/models/work_week.rb

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
class WorkWeek < ActiveRecord::Base
2-
include StaffPlan::AuditMethods
3-
42
has_paper_trail
53

64
attr_accessible :estimated_hours, :actual_hours, :beginning_of_week, :cweek, :year
@@ -14,27 +12,25 @@ class WorkWeek < ActiveRecord::Base
1412

1513
before_validation :set_beginning_of_week_if_blank
1614

17-
after_update :update_originator_timestamp
18-
1915
################################# SCOPES ####################################
2016

2117
scope :for_range, lambda { |lower, upper|
22-
if lower.cweek <= upper.cweek
23-
where(year: lower.year, cweek: Range.new(lower.cweek,upper.cweek))
24-
else # The date range spans over two years
18+
if lower.cweek <= upper.cweek
19+
where(year: lower.year, cweek: Range.new(lower.cweek,upper.cweek))
20+
else # The date range spans over two years
2521
query = "(cweek >= ? AND year = ?) OR (cweek <= ? AND year = ?)"
2622
where(query, lower.cweek, lower.year, upper.cweek, upper.year)
2723
end
2824
}
2925

30-
scope :with_hours, lambda { where("estimated_hours IS NOT NULL OR actual_hours IS NOT NULL") }
26+
scope :with_hours, lambda { where("estimated_hours IS NOT NULL OR actual_hours IS NOT NULL") }
3127

3228
def proposed?
3329
project.assignments.where(user_id: user.id).first.try(:proposed?) || false
3430
end
3531

3632
def set_beginning_of_week_if_blank
37-
if self.beginning_of_week.blank?
33+
if self.beginning_of_week.blank? && self.year.present? && self.cweek.present?
3834
self.beginning_of_week = Date.commercial(self.year, self.cweek).to_datetime.to_i
3935
end
4036
end

config/environments/development.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
# Show full error reports and disable caching
1313
config.consider_all_requests_local = true
1414
config.action_controller.perform_caching = false
15-
16-
# Don't care if the mailer can't send
17-
config.action_mailer.raise_delivery_errors = false
15+
16+
config.action_mailer.delivery_method = :smtp
17+
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
18+
config.action_mailer.raise_delivery_errors = true
1819
config.action_mailer.default_url_options = {host: "localhost", port: "3000"}
1920

2021
# Print deprecation notices to the Rails logger

0 commit comments

Comments
 (0)