Skip to content
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

Ruby 1.9 #15

Merged
merged 18 commits into from
Apr 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-gemset
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
freehub
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.9.3-p545
1 change: 0 additions & 1 deletion .rvmrc

This file was deleted.

6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
source :gemcutter, :rubygems
source 'https://rubygems.org'

gem "rails", "2.3.17"
gem "mysql"

gem "authorization", github: "asalant/rails-authorization-plugin"
gem 'json', '1.7.7' # (CVE-2013-026) Can remove once rails depends on > 1.7.6
gem 'haml', "3.0.25"
gem 'googlecharts', "1.6.0"
gem 'calendar_date_select', "1.16.1"
gem "acts-as-taggable-on", "2.0.6"
gem "newrelic_rpm"
gem 'hoptoad_notifier'
gem 'validates_email_format_of'

group :development, :test do
gem 'debugger'
gem 'rdoc'
gem 'annotate'
gem 'thoughtbot-shoulda'
Expand Down
34 changes: 26 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
GIT
remote: git://github.com/asalant/rails-authorization-plugin.git
revision: 505bd47addf2ef5e3b5d98a7ea8d1352c2aa4ee6
specs:
authorization (1.0.12)

GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
actionmailer (2.3.17)
actionpack (= 2.3.17)
Expand All @@ -12,18 +18,26 @@ GEM
activesupport (= 2.3.17)
activesupport (2.3.17)
acts-as-taggable-on (2.0.6)
annotate (2.5.0)
rake
builder (3.1.4)
annotate (2.6.2)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
builder (3.2.2)
calendar_date_select (1.16.1)
columnize (0.3.6)
debugger (1.6.6)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.3.2)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.2)
googlecharts (1.6.0)
haml (3.0.25)
hoptoad_notifier (2.4.11)
activesupport
builder
json (1.7.7)
mysql (2.9.0)
newrelic_rpm (3.5.5.38)
mysql (2.9.1)
newrelic_rpm (3.7.3.204)
rack (1.1.6)
rails (2.3.17)
actionmailer (= 2.3.17)
Expand All @@ -32,18 +46,21 @@ GEM
activeresource (= 2.3.17)
activesupport (= 2.3.17)
rake (>= 0.8.3)
rake (10.0.3)
rdoc (3.12)
rake (10.1.1)
rdoc (4.1.1)
json (~> 1.4)
thoughtbot-shoulda (2.11.1)
validates_email_format_of (1.5.3)

PLATFORMS
ruby

DEPENDENCIES
acts-as-taggable-on (= 2.0.6)
annotate
authorization!
calendar_date_select (= 1.16.1)
debugger
googlecharts (= 1.6.0)
haml (= 3.0.25)
hoptoad_notifier
Expand All @@ -53,3 +70,4 @@ DEPENDENCIES
rails (= 2.3.17)
rdoc
thoughtbot-shoulda
validates_email_format_of
4 changes: 0 additions & 4 deletions TODO

This file was deleted.

6 changes: 3 additions & 3 deletions app/controllers/reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def visits
stream_csv("#{@organization.key}_visits_#{@report[:after]}_#{@report[:before]}.csv") do |output|
output.write Visit.csv_header
@visits.each do |visit|
output.write "\n#{visit.to_csv}"
output.write "#{visit.to_csv}"
end
end
end
Expand Down Expand Up @@ -56,7 +56,7 @@ def services
stream_csv("#{@organization.key}_services_#{@report[:end_after]}_#{@report[:end_before]}.csv") do |output|
output.write CSV.generate_line(Service::CSV_FIELDS[:person] + Service::CSV_FIELDS[:self])
@services.each do |service|
output.write "\n#{service.to_csv}"
output.write "#{service.to_csv}"
end
end
end
Expand Down Expand Up @@ -84,7 +84,7 @@ def people
stream_csv("#{@organization.key}_people_#{@report[:after]}_#{@report[:before]}.csv") do |output|
output.write CSV.generate_line(Person::CSV_FIELDS[:self])
@people.each do |person|
output.write "\n#{person.to_csv}"
output.write "#{person.to_csv}"
end
end
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/taggings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ def create
@person.tag_list << params[:id]
@person.save!
if request.xhr?
@person.taggings.reload
index
else
redirect_to_person_path
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/people_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ def auto_complete_result_with_add_person(entries, field, phrase = nil)
return unless entries
items = entries.map do |entry|
content_tag("li", phrase ? highlight(entry[field], phrase) : h(entry[field]),
:class => 'person',
:url => person_path(:organization_key => @organization.key, :id => entry.id))
end
items << content_tag("li", content_tag("b", 'Add Person'),
:class => 'add',
:url => new_person_path(:organization_key => @organization.key))
content_tag("ul", items.uniq)
content_tag("ul", items.uniq.join(''))
end

end
10 changes: 5 additions & 5 deletions app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#

class Person < ActiveRecord::Base

belongs_to :organization
has_many :visits, :include => :note, :dependent => :destroy, :order => "arrived_at DESC"
has_many :services, :include => :note, :dependent => :destroy, :order => "end_date DESC" do
Expand All @@ -44,11 +44,11 @@ def on(service_type, time)
has_many :notes, :as => :notable, :dependent => :destroy

has_userstamps

validates_presence_of :first_name, :organization_id
validates_uniqueness_of :email, :scope => :organization_id, :case_sensitive => false, :allow_nil => true, :allow_blank => true
validates_length_of :first_name, :last_name, :street1, :street2, :city, :state, :postal_code, :country, :within => 1..40, :allow_blank => true
validates_email_veracity_of :email, :domain_check => true
validates_email_format_of :email, :check_mx => true, :allow_blank => true
# Note that Date.today gets evaluates at class load time, not evaluation time, but we can live with that fudge
validates_numericality_of :yob, :allow_nil => true, :only_integer => true, :greater_than => Date.today.year - 100, :less_than => Date.today.year + 1

Expand Down Expand Up @@ -84,7 +84,7 @@ def initialize(params={})
def membership
@membership ||= services.last(:membership)
end

def member?
!membership.nil? && membership.current?
end
Expand Down Expand Up @@ -156,4 +156,4 @@ def downcase_email
def update_full_name
self.full_name = [first_name, last_name].reject{|e| e.nil? || e.empty?}.join(' ')
end
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def accepts_role?(role, user)
validates_confirmation_of :password, :if => :password_required?
validates_length_of :login, :within => 3..40, :unless => proc { |user| user.errors.on :login }
validates_length_of :email, :within => 3..100, :unless => proc { |user| user.errors.on :email }
validates_email_veracity_of :email, :domain_check => true, :unless => proc { |user| user.errors.on :email }
validates_email_format_of :email, :check_mx=> true, :unless => proc { |user| user.errors.on :email }
validates_uniqueness_of :login, :email, :case_sensitive => false
before_save :encrypt_password
before_create :make_activation_code
Expand Down
4 changes: 3 additions & 1 deletion config/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

# Authorization plugin
AUTHORIZATION_MIXIN = 'object roles'
DEFAULT_REDIRECTION_HASH = { :controller => 'sessions', :action => 'new' }

PERMISSION_DENIED_REDIRECTION = { :controller => 'sessions', :action => 'new' }
LOGIN_REQUIRED_REDIRECTION = PERMISSION_DENIED_REDIRECTION
STORE_LOCATION_METHOD = :store_return_location

Rails::Initializer.run do |config|
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/visits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
#

mary_1:
arrived_at: 2007-02-01 18:01:00
arrived_at: <%= DateTime.parse('2007-02-01 18:01:00 PST') %>
volunteer: false
staff: false
member: true
person: mary

mary_2:
arrived_at: 2007-02-02 18:02:00
arrived_at: <%= DateTime.parse('2007-02-02 18:02:00 PST') %>
volunteer: true
staff: false
member: true
person: mary

<% (1..100).each do |count| %>
daryl_<%= count %>:
arrived_at: <%= DateTime.parse('2007-02-02 18:02:00').advance(:hours => count * -16) %>
arrived_at: <%= DateTime.parse('2007-02-02 18:02:00 PST').advance(:hours => count * -16) %>
person: daryl
<% end %>

Expand Down
26 changes: 21 additions & 5 deletions test/functional/people_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,27 @@ def test_requires_manager
assert_redirected_to new_session_path
end

def test_auto_complete
get :auto_complete_for_person_full_name, :organization_key => 'sfbk', :person => { :full_name => 'memb' }
assert_response :success
assert_not_nil assigns(:items)
assert_equal 1, assigns(:items).size
context "Auto-complete" do

setup do
get :auto_complete_for_person_full_name, :organization_key => 'sfbk', :person => { :full_name => 'memb' }
end

should respond_with :success
should assign_to :items

should 'find matching items' do
assert_equal 1, assigns(:items).size
end

should 'render list of people' do
assert_select 'ul li.person', 1
end

should 'render add link' do
assert_select 'ul li.add', 1
end

end

context "Update person" do
Expand Down
6 changes: 3 additions & 3 deletions test/functional/reports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_visits_report_csv
assert_nothing_raised { @response.body.call(@response, output) }
lines = output.string.split("\n")
assert_equal assigns(:visits).size + 1, lines.size
assert_equal Visit.csv_header, lines[0]
assert_equal Visit.csv_header, lines[0]+"\n"
assert_equal "attachment; filename=\"sfbk_visits_2006-01-01_2008-01-01.csv\"", @response.headers['Content-Disposition']
end

Expand Down Expand Up @@ -84,7 +84,7 @@ def test_services_report_csv
assert_nothing_raised { @response.body.call(@response, output) }
lines = output.string.split("\n")
assert_equal assigns(:services).size + 1, lines.size
assert_equal Service.csv_header, lines[0]
assert_equal Service.csv_header, lines[0]+"\n"
assert_equal "attachment; filename=\"sfbk_services_2006-01-01_2009-01-01.csv\"", @response.headers['Content-Disposition']
end

Expand Down Expand Up @@ -122,7 +122,7 @@ def test_people_report_csv
assert_nothing_raised { @response.body.call(@response, output) }
lines = output.string.split("\n")
assert_equal assigns(:people).size + 1, lines.size
assert_equal Person.csv_header, lines[0]
assert_equal Person.csv_header, lines[0]+"\n"
assert_equal "attachment; filename=\"sfbk_people_2008-01-01_2008-01-05.csv\"", @response.headers['Content-Disposition']
end

Expand Down
4 changes: 4 additions & 0 deletions test/functional/taggings_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class TaggingsControllerTest < ActionController::TestCase
should 'have the new tag' do
assert_equal ['mechanic', 'mom', 'three'], people(:mary).tag_list
end

should 'render links to delete tags' do
assert_select '.tags_control .edit .tag a.delete', 3
end
end

end
Expand Down
2 changes: 1 addition & 1 deletion test/unit/person_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_membership_on
end

def test_csv_header
assert_equal 'id,first_name,last_name,staff,email,email_opt_out,phone,postal_code,street1,street2,city,state,postal_code,country,yob,created_at,membership_expires_on', Person.csv_header
assert_equal "id,first_name,last_name,staff,email,email_opt_out,phone,postal_code,street1,street2,city,state,postal_code,country,yob,created_at,membership_expires_on\n", Person.csv_header
end

def test_to_csv
Expand Down
2 changes: 1 addition & 1 deletion test/unit/service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_current
end

def test_csv_header
assert_equal 'first_name,last_name,email,email_opt_out,phone,postal_code,service_type_id,start_date,end_date,volunteered,paid,note', Service.csv_header
assert_equal "first_name,last_name,email,email_opt_out,phone,postal_code,service_type_id,start_date,end_date,volunteered,paid,note\n", Service.csv_header
end

def test_to_csv
Expand Down
2 changes: 1 addition & 1 deletion test/unit/visit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_to_csv
end

def test_csv_header
assert_equal 'first_name,last_name,email,email_opt_out,phone,postal_code,arrived_at,staff,member,volunteer,note', Visit.csv_header
assert_equal "first_name,last_name,email,email_opt_out,phone,postal_code,arrived_at,staff,member,volunteer,note\n", Visit.csv_header
end

def test_create_defaults
Expand Down
Loading