Skip to content

Commit

Permalink
Merge pull request #50 from team-umlaut/rails42
Browse files Browse the repository at this point in the history
Support rails 4.2 with travis passing,  closes #49
  • Loading branch information
jrochkind committed Feb 25, 2015
2 parents 0bb3949 + 3a66eb7 commit a16bfdf
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -33,6 +33,7 @@ end

group :debug do
gem 'debugger', :platform => :mri_19
gem 'ruby-debug', :platform => :jruby
end

# Add coveralls for testing.
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/export_email_controller.rb
Expand Up @@ -11,7 +11,7 @@ def send_email
@fulltexts = @user_request.get_service_type('fulltext', { :refresh=>true })
@holdings = @user_request.get_service_type('holding', { :refresh=>true })
if valid_email?
Emailer.citation(@email, @user_request, @fulltexts, @holdings).deliver
action_mailer_deliver Emailer.citation(@email, @user_request, @fulltexts, @holdings)
else
flash[:alert] = email_validation_error
render :email and return
Expand All @@ -29,7 +29,7 @@ def send_txt
@email = "#{@number}@#{@provider}" unless @number.nil? or @provider.nil?
@holding = params[:holding]
if valid_txt_number? && valid_txt_holding?
Emailer.short_citation(@email, @user_request, holding_location(@holding), call_number(@holding)).deliver
action_mailer_deliver Emailer.short_citation(@email, @user_request, holding_location(@holding), call_number(@holding))
else
flash[:alert] = txt_validation_error
render :txt and return
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/feedback_controller.rb
Expand Up @@ -15,7 +15,7 @@ def create
)
end

FeedbackMailer.feedback(request.host_with_port, to_address, options).deliver
action_mailer_deliver FeedbackMailer.feedback(request.host_with_port, to_address, options)

flash[:alert_success] = "Thanks, your message has been sent."

Expand Down
14 changes: 14 additions & 0 deletions app/controllers/umlaut/controller_behavior.rb
Expand Up @@ -87,6 +87,20 @@ def specified_service_groups(arg_params = params)
end
protected :specified_service_groups

# Call an ActionMailer::Base without deprecation warnings in Rails 4.3,
# but still work in earlier rails without deliver_later
#
# Calls with deliver_later in Rails 4.3. If no ActiveJob queue
# is set up, no problem default is immediate executor anyway.
def action_mailer_deliver(mailer)
if mailer.respond_to?(:deliver_later)
mailer.deliver_later
else
mailer.deliver
end
end
protected :action_mailer_deliver



end
8 changes: 7 additions & 1 deletion app/models/referent.rb
Expand Up @@ -390,11 +390,17 @@ def remove_value(key)

# options => { :overwrite => false } to only enhance if not already there
def enhance_referent(key, value, metadata=true, private_data=false, options = {})


ActiveRecord::Base.connection_pool.with_connection do
return if value.nil?

matches = self.referent_values.to_a.find_all do |rv|
(rv.key_name == key) && (rv.metadata == metadata) && (rv.private_data == private_data)
# We ignore #metadata and #private_data matches in overwriting
# existing value. We used to take them into account, but it triggered
# a bug in Jruby, and pretty much isn't neccesary, those fields
# are pretty useless and mostly not used and should prob be removed.
(rv.key_name == key) # && (rv.metadata == metadata) && (rv.private_data == private_data)
end

matches.each do |rv|
Expand Down
2 changes: 1 addition & 1 deletion lib/umlaut/version.rb
Expand Up @@ -4,5 +4,5 @@ module Umlaut
# This is used in Umlaut's .gemspec for generating the gem,
# and is also used in the umlaut app generator to make sure
# we're generating with a compatible Rails version.
RAILS_COMPAT_SPEC = [">= 3.2.12", "< 4.2.0"]
RAILS_COMPAT_SPEC = [">= 3.2.12", "< 4.3.0"]
end
2 changes: 1 addition & 1 deletion test/dummy/config/environments/test.rb
Expand Up @@ -38,5 +38,5 @@
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr


config.active_support.test_order = :random
end
9 changes: 8 additions & 1 deletion test/functional/resolve_controller_test.rb
Expand Up @@ -106,7 +106,14 @@ def create_collection
assert_equal 1, holdings.size
holdings.each do |holding|
# Make sure the edition warning shows up.
assert_select holding, ".umlaut-holding-match-reliability", 1
#assert_select holding, ".umlaut-holding-match-reliability", 1
#
# For some reason above triggering a bug in Rails 4.2 and Jruby,
# doesn't make sense, so we'll do it this way which mysteriously works,
# and does the same thing.
match_reliability_warning = css_select(".umlaut-holding-match-reliability")
assert match_reliability_warning.length == 1, "Expected exactly 1 element matching '.umlaut-holding-match-reliability', found #{match_reliability_warning.length}"

# Make sure the coverage shows up.
assert_select holding, ".umlaut-holding-coverage", 1
assert_select holding, ".umlaut-holding-coverage li", 2
Expand Down
4 changes: 2 additions & 2 deletions test/unit/feedback_mailer_test.rb
Expand Up @@ -17,7 +17,7 @@ class FeedbackMailerTest < ActionMailer::TestCase
feedback_email = "joe@example.org"
feedback_text = "This is my feedback, yes it is"

email = FeedbackMailer.feedback(@host, @to_email, :umlaut_request => umlaut_request, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver
email = FeedbackMailer.feedback(@host, @to_email, :umlaut_request => umlaut_request, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver_now

assert ActionMailer::Base.deliveries.present?
assert_equal [UmlautController.umlaut_config.from_email_addr], email.from
Expand Down Expand Up @@ -48,7 +48,7 @@ class FeedbackMailerTest < ActionMailer::TestCase
feedback_email = "joe@example.org"
feedback_text = "This is my feedback, yes it is"

email = FeedbackMailer.feedback(@host, @to_email, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver
email = FeedbackMailer.feedback(@host, @to_email, :name => feedback_name, :email => feedback_email, :feedback => feedback_text).deliver_now
# just no raise is good enough for this test for now, mostly

assert_includes email.body, "No citation supplied"
Expand Down

0 comments on commit a16bfdf

Please sign in to comment.