Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merging in changes from master, adding back test_app - but just the t…

…est files
  • Loading branch information...
commit 755555a5f0cb8e76ca374e68aa4292ec024340cd 2 parents 4945cbb + 4c4bcf3
Dan Funk authored
Showing with 459 additions and 313 deletions.
  1. +0 −1  .gitignore
  2. +12 −9 app/controllers/catalog_controller.rb
  3. +16 −9 app/controllers/folder_controller.rb
  4. +15 −15 app/helpers/blacklight_helper.rb
  5. +8 −7 app/helpers/catalog_helper.rb
  6. +1 −1  app/helpers/hash_as_hidden_fields.rb
  7. +13 −13 app/helpers/render_constraints_helper.rb
  8. +43 −44 app/models/record_mailer.rb
  9. +11 −5 app/views/catalog/_folder_control.html.erb
  10. +10 −10 app/views/catalog/_sort_and_per_page.html.erb
  11. +9 −8 app/views/folder/index.html.erb
  12. +2 −1  app/views/record_mailer/email_record.erb
  13. +1 −1  app/views/record_mailer/sms_record.erb
  14. +2 −2 blacklight.gemspec
  15. +1 −1  config/routes.rb
  16. +3 −3 lib/blacklight/solr_helper.rb
  17. +0 −1  lib/generators/blacklight/blacklight_generator.rb
  18. +1 −1  lib/generators/blacklight/templates/config/blacklight_config.rb
  19. +0 −28 lib/generators/blacklight/templates/migrations/remove_acts_as_taggable.rb
  20. +75 −57 lib/generators/blacklight/templates/public/javascripts/blacklight.js
  21. +6 −4 lib/generators/blacklight/templates/public/stylesheets/blacklight.css
  22. +1 −0  lib/railties/blacklight.rake
  23. +4 −3 lib/railties/solr_marc.rake
  24. +99 −0 spec/helpers/catalog_helper_spec.rb
  25. +19 −0 spec/views/catalog/_sms_form.html.erb_spec.rb
  26. +3 −4 test_app/.gitignore
  27. +34 −34 test_app/features/folder.feature
  28. +6 −0 test_app/spec/controllers/catalog_controller_spec.rb
  29. +8 −8 test_app/spec/controllers/folder_controller_spec.rb
  30. +9 −7 test_app/spec/helpers/solr_helper_spec.rb
  31. +32 −31 test_app/spec/lib/tasks/solr_marc_task_spec.rb
  32. +15 −5 test_app/spec/models/record_mailer_spec.rb
View
1  .gitignore
@@ -8,7 +8,6 @@ jetty/logs/*.log
jetty/solr/data/*
log/*
webrat-*
-public/
config/SolrMarc/*.log*
rerun.txt
solr_marc/solrmarc.log
View
21 app/controllers/catalog_controller.rb
@@ -1,3 +1,5 @@
+
+
class CatalogController < BlacklightController
include Blacklight::SolrHelper
@@ -15,13 +17,13 @@ class CatalogController < BlacklightController
# When RSolr::RequestError is raised, the rsolr_request_error method is executed.
# The index action will more than likely throw this one.
# Example, when the standard query parser is used, and a user submits a "bad" query.
- rescue_from RSolr::RequestError, :with => :rsolr_request_error
-
+ rescue_from RSolr::Error::Http, :with => :rsolr_request_error
+
# get search results from the solr index
def index
- extra_head_content << '<link rel="alternate" type="application/rss+xml" title="RSS for results" href="'+ url_for(params.merge("format" => "rss")) + '">'
- extra_head_content << '<link rel="alternate" type="application/atom+xml" title="Atom for results" href="'+ url_for(params.merge("format" => "atom")) + '">'
+ extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => "RSS for results")
+ extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => "Atom for results")
(@response, @document_list) = get_search_results
@filters = params[:f] || []
@@ -118,22 +120,23 @@ def send_email_record
@response, @documents = get_solr_response_for_field_values("id",params[:id])
if params[:to]
from = request.host # host w/o port for From address (from address cannot have port#)
- host = request.host
- host << ":#{request.port}" unless request.port.nil? # host w/ port for linking
+ url_gen_params = {:host => request.host_with_port, :protocol => request.protocol}
+
case params[:style]
when 'sms'
+ phone_num = params[:to].gsub(/[^\d]/, '')
if !params[:carrier].blank?
- if params[:to].length != 10
+ if phone_num.length != 10
flash[:error] = "You must enter a valid 10 digit phone number"
else
- email = RecordMailer.create_sms_record(@documents, {:to => params[:to], :carrier => params[:carrier]}, from, host)
+ email = RecordMailer.create_sms_record(@documents, {:to => phone_num, :carrier => params[:carrier]}, from, url_gen_params)
end
else
flash[:error] = "You must select a carrier"
end
when 'email'
if params[:to].match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/)
- email = RecordMailer.create_email_record(@documents, {:to => params[:to], :message => params[:message]}, from, host)
+ email = RecordMailer.create_email_record(@documents, {:to => params[:to], :message => params[:message]}, from, url_gen_params)
else
flash[:error] = "You must enter a valid email address"
end
View
25 app/controllers/folder_controller.rb
@@ -6,9 +6,10 @@ class FolderController < BlacklightController
def index
@response, @documents = get_solr_response_for_field_values("id",session[:folder_document_ids] || [])
end
+
- # add a document_id to the folder
- def create
+ # add a document_id to the folder. :id of action is solr doc id
+ def update
session[:folder_document_ids] = session[:folder_document_ids] || []
session[:folder_document_ids] << params[:id]
# Rails 3 uses a one line notation for setting the flash notice.
@@ -19,19 +20,25 @@ def create
end
end
- # remove a document_id from the folder
+ # remove a document_id from the folder. :id of action is solr_doc_id
def destroy
session[:folder_document_ids].delete(params[:id])
- flash[:notice] = "#{params[:title] || "Item"} successfully removed from Folder"
- respond_to do |format|
- format.html { redirect_to :back }
- format.js { render :json => session[:folder_document_ids] }
- end
+
+ unless request.xhr?
+ respond_to do |format|
+ format.html do
+ flash[:notice] = "#{params[:title] || "Item"} successfully removed from selected items"
+ redirect_to :back
+ end
+ end
+ else
+ render :text => "OK"
+ end
end
# get rid of the items in the folder
def clear
- flash[:notice] = "Cleared Folder"
+ flash[:notice] = "Cleared Selected Items"
session[:folder_document_ids] = []
respond_to do |format|
format.html { redirect_to :back }
View
30 app/helpers/blacklight_helper.rb
@@ -130,7 +130,7 @@ def render_link_rel_alternates(document=@document, options = {})
seen.add(spec[:content_type]) if options[:unique]
end
end
- return html
+ return html.html_safe
end
def render_opensearch_response_metadata
@@ -175,21 +175,23 @@ def render_facet_limit(solr_field)
def render_document_list_partial options={}
render :partial=>'catalog/document_list'
end
-
# Save function area for search results 'index' view, normally
# renders next to title. Includes just 'Folder' by default.
def render_index_doc_actions(document, options={})
content_tag("div", :class=>"documentFunctions") do
- "#{render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))}
- #{render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options))}".html_safe
+ raw("#{render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options))}
+ #{render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))}")
end
end
# Save function area for item detail 'show' view, normally
# renders next to title. By default includes 'Folder' and 'Bookmarks'
def render_show_doc_actions(document=@document, options={})
- render_index_doc_actions(document, options)
+ content_tag("div", :class=>"documentFunctions") do
+ raw("#{render(:partial => 'bookmark_control', :locals => {:document=> document}.merge(options))}
+ #{render(:partial => 'folder_control', :locals => {:document=> document}.merge(options))}")
+ end
end
# used in the catalog/_index_partials/_default view
@@ -222,7 +224,7 @@ def document_heading
@document[Blacklight.config[:show][:heading]] || @document.id
end
def render_document_heading
- '<h1>' + document_heading + '</h1>'
+ content_tag(:h1, document_heading)
end
# Used in the show view for setting the main html document title
@@ -233,7 +235,7 @@ def document_show_html_title
# Used in citation view for displaying the title
def citation_title(document)
document[Blacklight.config[:show][:html_title]]
- end
+I end
# Used in the document_list partial (search view) for building a select element
def sort_fields
@@ -273,7 +275,7 @@ def render_document_show_field_value args
def render_field_value value=nil
value = [value] unless value.is_a? Array
- return value.map { |v| v.html_safe }.join field_value_separator
+ return value.map { |v| html_escape v }.join(field_value_separator).html_safe
end
def field_value_separator
@@ -315,16 +317,14 @@ def link_to_previous_search(params)
# options consist of:
# :suppress_link => true # do not make it a link, used for an already selected value for instance
def render_facet_value(facet_solr_field, item, options ={})
- link_to_unless(options[:suppress_link], item.value, add_facet_params_and_redirect(facet_solr_field, item.value), :class=>"facet_select label") + " " + render_facet_count(item.hits)
+ (link_to_unless(options[:suppress_link], item.value, add_facet_params_and_redirect(facet_solr_field, item.value), :class=>"facet_select label") + " " + render_facet_count(item.hits)).html_safe
end
# Standard display of a SELECTED facet value, no link, special span
# with class, and 'remove' button.
def render_selected_facet_value(facet_solr_field, item)
- '<span class="selected label">' +
- render_facet_value(facet_solr_field, item, :suppress_link => true) +
- '</span>' +
- link_to("[remove]", remove_facet_params(facet_solr_field, item.value, params), :class=>"remove")
+ content_tag(:span, render_facet_value(facet_solr_field, item, :suppress_link => true), :class => "selected label") +
+ link_to("[remove]", remove_facet_params(facet_solr_field, item.value, params), :class=>"remove")
end
# Renders a count value for facet limits. Can be over-ridden locally
@@ -418,8 +418,8 @@ def link_to_query(query)
def render_document_index_label doc, opts
label = nil
label ||= doc.get(opts[:label]) if opts[:label].instance_of? Symbol
- label ||= opts[:label] if opts[:label].instance_of? String
label ||= opts[:label].call(doc, opts) if opts[:label].instance_of? Proc
+ label ||= opts[:label] if opts[:label].is_a? String
label ||= doc.id
end
@@ -511,7 +511,7 @@ def link_to_with_data(*args, &block)
end
href_attr = "href=\"#{url}\"" unless href
- "<a #{href_attr}#{tag_options}>#{h(name) || h(url)}</a>"
+ "<a #{href_attr}#{tag_options}>#{h(name) || h(url)}</a>".html_safe
end
end
View
15 app/helpers/catalog_helper.rb
@@ -11,23 +11,24 @@ def format_num(num); number_with_delimiter(num) end
# an RSolr::Ext::Response works. Perhaps it duck-types to something
# from will_paginate?
def page_entries_info(collection, options = {})
- start = collection.next_page == 2 ? 1 : collection.previous_page * collection.per_page + 1
+ start = (collection.current_page - 1) * collection.per_page + 1
total_hits = @response.total
start_num = format_num(start)
- end_num = format_num(start + collection.per_page - 1)
+ end_num = format_num(start + collection.size - 1)
total_num = format_num(total_hits)
+ # end_num = total_num if total_hits < (start + collection.per_page - 1)
entry_name = options[:entry_name] ||
(collection.empty?? 'entry' : collection.first.class.name.underscore.sub('_', ' '))
if collection.total_pages < 2
case collection.size
- when 0; "No #{entry_name.pluralize} found"
- when 1; "Displaying <b>1</b> #{entry_name}"
- else; "Displaying <b>all #{total_num}</b> #{entry_name.pluralize}"
+ when 0; "No #{h(entry_name.pluralize)} found".html_safe
+ when 1; "Displaying <b>1</b> #{h(entry_name)}".html_safe
+ else; "Displaying <b>all #{total_num}</b> #{entry_name.pluralize}".html_safe
end
else
- "Displaying #{entry_name.pluralize} <b>#{start_num} - #{end_num}</b> of <b>#{total_num}</b>"
+ "Displaying #{h(entry_name.pluralize)} <b>#{start_num} - #{end_num}</b> of <b>#{total_num}</b>".html_safe
end
end
@@ -36,7 +37,7 @@ def page_entries_info(collection, options = {})
# Code should call this method rather than interrogating session directly,
# because implementation of where this data is stored/retrieved may change.
def item_page_entry_info
- "Showing item <b>#{session[:search][:counter].to_i} of #{format_num(session[:search][:total])}</b> from your search."
+ "Showing item <b>#{session[:search][:counter].to_i} of #{format_num(session[:search][:total])}</b> from your search.".html_safe
end
# Look up search field user-displayable label
View
2  app/helpers/hash_as_hidden_fields.rb
@@ -23,7 +23,7 @@ def hash_as_hidden_fields(hash)
end
end
- hidden_fields.join("\n")
+ hidden_fields.join("\n").html_safe
end
protected
View
26 app/helpers/render_constraints_helper.rb
@@ -95,26 +95,26 @@ def render_search_to_s_filters(params)
params[:f].collect do |facet_field, value_list|
render_search_to_s_element(Blacklight.config[:facet][:labels][facet_field],
value_list.collect do |value|
- "<span class='filterValue'>#{h(value)}</span>"
- end.join(" <span class='label'>and</span> "),
- :escape_value => false
+ render_filter_value(value)
+ end.join(content_tag(:span, 'and', :class =>'label'))
)
- end.join(" \n ")
+ end.join(" \n ").html_safe
end
# value can be Array, in which case elements are joined with
# 'and'. Pass in option :escape_value => false to pass in pre-rendered
# html for value. key with escape_key if needed.
def render_search_to_s_element(key, value, options = {})
- options[:escape_value] = true unless options.has_key?(:escape_value)
- options[:escape_key] = true unless options.has_key?(:escape_key)
-
- key = h(key) if options[:escape_key]
- value = h(value) if options[:escape_value]
-
- "<span class='constraint'>" +
- (key.blank? ? "" : "<span class='filterName'>#{key}:</span>") +
- "<span class='filterValue'>#{value}</span></span>"
+ content_tag(:span, render_filter_name(key) + render_filter_value(value), :class => 'constraint')
+ end
+
+ def render_filter_name name
+ return "" if name.blank?
+ content_tag(:span, h(name) + ":", :class => 'filterName')
+ end
+
+ def render_filter_value value
+ content_tag(:span, h(value), :class => 'filterValue')
end
end
View
87 app/models/record_mailer.rb
@@ -1,44 +1,43 @@
-# Only works for documents with a #to_marc right now.
-class RecordMailer < ActionMailer::Base
-
-
- def email_record(documents, details, from_host, host)
- #raise ArgumentError.new("RecordMailer#email_record only works with documents with a #to_marc") unless document.respond_to?(:to_marc)
-
- recipients details[:to]
- if documents.size == 1
- subject = "Item Record: #{documents.first.to_marc['245']['a'] rescue 'N/A'}"
- else
- subject = "Item records"
- end
-
- @documents = documents
- @message = details[:message]
- @host = host
-
- mail(:to => details[:to], :from => "no-reply@" << from_host, :subject => subject)
-
- end
-
- def sms_record(documents, details, from_host, host)
- if sms_mapping[details[:carrier]]
- to = "#{details[:to]}@#{sms_mapping[details[:carrier]]}"
- end
- @documents = documents
- @host = host
- mail(:to => to, :from => "no-reply@" << from_host, :subject => "")
- end
-
- protected
-
- def sms_mapping
- {'virgin' => 'vmobl.com',
- 'att' => 'txt.att.net',
- 'verizon' => 'vtext.com',
- 'nextel' => 'messaging.nextel.com',
- 'sprint' => 'messaging.sprintpcs.com',
- 'tmobile' => 'tmomail.net',
- 'alltel' => 'message.alltel.com',
- 'cricket' => 'mms.mycricket.com'}
- end
-end
+# Only works for documents with a #to_marc right now.
+class RecordMailer < ActionMailer::Base
+
+ def email_record(documents, details, from_host, url_gen_params)
+ #raise ArgumentError.new("RecordMailer#email_record only works with documents with a #to_marc") unless document.respond_to?(:to_marc)
+
+ recipients details[:to]
+ if documents.size == 1
+ subject = "Item Record: #{documents.first.to_marc['245']['a'] rescue 'N/A'}"
+ else
+ subject = "Item records"
+ end
+
+ @documents = documents
+ @message = details[:message]
+ @url_gen_params = url_gen_params
+
+ mail(:to => details[:to], :from => "no-reply@" << from_host, :subject => subject)
+ end
+
+ def sms_record(documents, details, from_host, url_gen_params)
+ if sms_mapping[details[:carrier]]
+ to = "#{details[:to]}@#{sms_mapping[details[:carrier]]}"
+ end
+ @documents = documents
+ @host = host
+ @url_gen_params = url_gen_params
+ mail(:to => to, :from => "no-reply@" << from_host, :subject => "")
+ end
+
+ protected
+
+ def sms_mapping
+ {'virgin' => 'vmobl.com',
+ 'att' => 'txt.att.net',
+ 'verizon' => 'vtext.com',
+ 'nextel' => 'messaging.nextel.com',
+ 'sprint' => 'messaging.sprintpcs.com',
+ 'tmobile' => 'tmomail.net',
+ 'alltel' => 'message.alltel.com',
+ 'cricket' => 'mms.mycricket.com'}
+ end
+end
View
16 app/views/catalog/_folder_control.html.erb
@@ -1,6 +1,12 @@
-<%- # would like to find a better way to determine the path, but the routes weren't working as expected and passing a hash causes route matching errors in cucumber -%>
-<%= form_tag("/folder#{item_in_folder?(document[:id]) ? '/destroy' : nil}", :name => "folder#{document[:id]}", :class=>"#{item_in_folder?(document[:id]) ? "delete" : "add"}Folder", :title=>h(document[document_show_link_field])) do %>
- <%= hidden_field_tag("id_#{document[:id]}".to_sym, h(document[:id]), :name=>"id") %>
- <%= hidden_field_tag("title_#{document[:id]}".to_sym, h(document[document_show_link_field]), :name=>"title" ) %>
- <%= submit_tag (item_in_folder?(document[:id]) ? "Unselect" : "Select"), :class=>"folder_submit", :id => "folder_submit_#{document[:id]}" %>
+<%-
+ # pass in local :document with a SolrDocument
+ method = (item_in_folder?(document[:id]) ? "delete" : "put")
+ label = (item_in_folder?(document[:id]) ? "Unselect" : "Select")
+ cssClass = (item_in_folder?(document[:id]) ? "deleteFolder" : "addFolder")
+-%>
+
+<%= form_tag( folder_path(document[:id]), :method => method, :class=> "folder_toggle #{cssClass}", "data-doc-id" => document[:id], :title=>h(document[document_show_link_field])) do -%>
+ <%= hidden_field(:bookmark, :title, :value => document[document_show_link_field]) %>
+ <%= submit_tag(label, :class=>"folder_submit", :id => "folder_submit_#{document[:id]}") %>
<% end %>
+
View
20 app/views/catalog/_sort_and_per_page.html.erb
@@ -2,19 +2,19 @@
<% unless @response.response['numFound'] < 2 %>
<%-# kind of hacky way to get this to work on catalog and folder controllers. May be able to simple do {:action=>"index"} but I'm not sure -%>
<%= form_tag params[:controller] == "folder" ? folder_index_path : catalog_index_path, :method=>:get, :class=>'per_page' do %>
- Show <%= label_tag(:per_page, select_tag(:per_page, options_for_select(['10', '20', '50', '100'], params[:per_page]), :title => "Number of results to display per page", :onchange => 'this.form.submit()') + " per page") %>
- <%= raw(search_as_hidden_fields(:omit_keys => [:page, :per_page])) %>
- <noscript><%= submit_tag 'update' %></noscript>
+ <%= label_tag(:per_page) do %>
+ Show <%= select_tag(:per_page, options_for_select(['10', '20', '50', '100'], h(params[:per_page])), :title => "Number of results to display per page") %> per page
+ <% end %>
+ <%= search_as_hidden_fields(:omit_keys => [:page, :per_page]) %>
+ <%= submit_tag 'update' %>
<% end %>
<%-# kind of hacky way to get this to work on catalog and folder controllers. May be able to simple do {:action=>"index"} but I'm not sure -%>
- <%= form_tag params[:controller] == "folder" ? folder_index_path : catalog_index_path, :method=>:get, :class=>'sort', :id => "sort_form" do %>
-
- <%= label_tag(:sort, "Sort by ") %>
- <%= select_tag(:sort, options_for_select(sort_fields, h(params[:sort])), :onchange => 'this.form.submit()') %>
- <%= raw(search_as_hidden_fields(:omit_keys => [:page, :sort])) %>
- <noscript><%= submit_tag 'sort results' %></noscript>
+ <% form_tag params[:controller] == "folder" ? folder_index_path : catalog_index_path, :method=>:get, :class=>'sort', :id => "sort_form" do %>
+ <%= label_tag(:sort, "Sort by ") %>
+ <%= select_tag(:sort, options_for_select(sort_fields, h(params[:sort]))) %>
+ <%= search_as_hidden_fields(:omit_keys => [:page, :sort]) %>
+ <%= submit_tag 'sort results' %>
<% end %>
-
<% end %>
</div>
View
17 app/views/folder/index.html.erb
@@ -10,7 +10,7 @@
<%= render "catalog/results_pagination" %>
<ul class="folderTools">
<li class="cite">
- <%= link_to "Cite", citation_catalog_path(:id => @documents.collect{|doc| doc.get(:id)}), {:id => 'citeLink', :name => 'citation', :class => 'lightboxLink'} %>
+ <%= link_to "Cite", citation_catalog_path(:id => @documents.collect{|doc| doc.get(:id)}), {:id => 'citeLink', :name => 'citation'} %>
</li>
<li class="refworks">
<%= render :partial => 'catalog/refworks_form', :locals => {:documents=>@documents} %>
@@ -19,7 +19,7 @@
<%= link_to "Export to EndNote", endnote_catalog_path(:id => @documents.collect {|doc| doc.get(:id)}, :format => 'endnote')%>
</li>
<li class="email">
- <%= link_to "Email", email_catalog_path(:id => @documents.collect {|doc| doc.get(:id)}), :class=>"lightboxLink" %>
+ <%= link_to "Email", email_catalog_path(:id => @documents.collect {|doc| doc.get(:id)}), :class=>"lightboxLink", :id => "emailLink" %>
</li>
<li class="sms">
<%= link_to "SMS", sms_catalog_path(:id => @documents.collect {|doc| doc.get(:id)}), :class=>"lightboxLink" %>
@@ -40,15 +40,16 @@
<% # container for a single doc -%>
<div class="document">
<% # header bar for doc items in index view -%>
- <div class="documentHeader yui-g">
- <div class="yui-u documentFunctions">
+ <div class="documentHeader">
+ <div class="documentFunctions">
<div class="in_folder">
<%= render :partial=>'catalog/folder_control', :locals=>{:document=>document} %>
</div>
- </div>
- <div class="yui-u">
- <h3 class="index_title"><%= i + 1 + @response.params[:start].to_i%>. <%= link_to_document document, :label => document_show_link_field, :results_view => false %></h3>
- </div>
+ </div>
+
+ <h3 class="index_title"><%= i + 1 + @response.params[:start].to_i%>. <%= link_to_document document, :label => document_show_link_field, :results_view => false %></h3>
+
+
</div>
<%= render_document_partial document, :index %>
View
3  app/views/record_mailer/email_record.erb
@@ -6,7 +6,8 @@
<%= "Author: #{document.to_marc['100']['a']}" unless document.to_marc['100']['a'].nil? %>
<% end -%>
Format: <%= document[Blacklight.config[:show][:display_type]] %>
-URL: <%= catalog_path(document[:id], :only_path => false, :host => @host) %>
+URL: <%= catalog_path(document[:id], {:only_path => false}.merge(@url_gen_params)) %>
+
<% end %>
Message: <%= @message %>
View
2  app/views/record_mailer/sms_record.erb
@@ -5,5 +5,5 @@
<%- if document.to_marc and ! document.to_marc['100'].nil? -%>
<%= " by #{document.to_marc['100']['a']}" unless document.to_marc['100']['a'].nil? %>
<% end -%>
-Link: <%= catalog_path(document[:id], :only_path => false, :host => @host) %>
+Link: <%= catalog_path(document[:id], {:only_path => false}.merge(@url_gen_params) ) %>
<% end %>
View
4 blacklight.gemspec
@@ -41,8 +41,8 @@ Gem::Specification.new do |s|
s.add_dependency "acts-as-taggable-on"
s.add_dependency "paperclip"
s.add_dependency "capistrano"
- s.add_dependency "rsolr", '0.12.1' # source :gemcutter
- s.add_dependency "rsolr-ext", '0.12.1' # source :gemcutter
+ s.add_dependency "rsolr", '1.0.0' # source :gemcutter
+ s.add_dependency "rsolr-ext", '1.0.0' # source :gemcutter
# For testing the generators
s.add_dependency "rspec-rails", "~>2.3.0"
View
2  config/routes.rb
@@ -22,7 +22,7 @@
# folder_path helper method is created automatically and sets an action of "delete"
match "folder/clear", :to => "folder#clear", :as => "clear_folder"
match "folder/destroy", :to => "folder#destroy"
- resources :folder, :only => [:index, :create, :destroy]
+ resources :folder, :only => [:index, :update, :destroy]
# Search History
match "search_history/clear", :to => "search_history#clear", :as => "clear_search_history"
View
6 lib/blacklight/solr_helper.rb
@@ -205,7 +205,7 @@ def get_search_results(extra_controller_params={})
solr_response = Blacklight.solr.find( self.solr_search_params(extra_controller_params) )
- document_list = solr_response.docs.collect {|doc| SolrDocument.new(doc)}
+ document_list = solr_response.docs.collect {|doc| SolrDocument.new(doc, solr_response)}
Rails.logger.debug("Solr fetch: #{self.class}#get_search_results (#{'%.1f' % ((Time.now.to_f - bench_start.to_f)*1000)}ms)")
@@ -230,7 +230,7 @@ def solr_doc_params(id=nil, extra_controller_params={})
def get_solr_response_for_doc_id(id=nil, extra_controller_params={})
solr_response = Blacklight.solr.find solr_doc_params(id, extra_controller_params)
raise InvalidSolrID.new if solr_response.docs.empty?
- document = SolrDocument.new(solr_response.docs.first)
+ document = SolrDocument.new(solr_response.docs.first, solr_response)
[solr_response, document]
end
@@ -245,7 +245,7 @@ def get_solr_response_for_field_values(field, values, extra_controller_params={}
'spellcheck' => 'false'
}
solr_response = Blacklight.solr.find( self.solr_search_params(solr_params.merge(extra_controller_params)) )
- document_list = solr_response.docs.collect{|doc| SolrDocument.new(doc) }
+ document_list = solr_response.docs.collect{|doc| SolrDocument.new(doc, solr_response) }
[solr_response,document_list]
end
View
1  lib/generators/blacklight/blacklight_generator.rb
@@ -66,7 +66,6 @@ def copy_migrations
# Can't get this any more DRY, because we need this order.
better_migration_template "create_searches.rb"
better_migration_template "create_bookmarks.rb"
- better_migration_template "remove_acts_as_taggable.rb"
better_migration_template "remove_editable_fields_from_bookmarks.rb"
better_migration_template "add_user_types_to_bookmarks_searches.rb"
end
View
2  lib/generators/blacklight/templates/config/blacklight_config.rb
@@ -100,7 +100,7 @@
# sniffing requires solr requests to be made with "echoParams=all", for
# app code to actually have it echo'd back to see it.
:limits => {
- "subject_facet" => 20,
+ "subject_topic_facet" => 20,
"language_facet" => true
}
}
View
28 lib/generators/blacklight/templates/migrations/remove_acts_as_taggable.rb
@@ -1,28 +0,0 @@
-class RemoveActsAsTaggable < ActiveRecord::Migration
- def self.up
- drop_table :taggings
- drop_table :tags
- end
-
- def self.down
- create_table :tags do |t|
- t.column :name, :string
- end
-
- create_table :taggings do |t|
- t.column :tag_id, :integer
- t.column :taggable_id, :integer
-
- # You should make sure that the column created is
- # long enough to store the required class names.
- t.column :taggable_type, :string
-
- t.column :created_at, :datetime
- end
-
- add_index :taggings, :tag_id
- add_index :taggings, [:taggable_id, :taggable_type]
- end
-
-
-end
View
132 lib/generators/blacklight/templates/public/javascripts/blacklight.js
@@ -43,6 +43,8 @@ Blacklight = {};
$(document).ready(function() {
Blacklight.do_zebra_stripe();
+ Blacklight.do_select_submit();
+
Blacklight.do_more_facets_behavior();
Blacklight.do_lightbox_dialog();
@@ -75,6 +77,20 @@ $(document).ready(function() {
};
Blacklight.do_more_facets_behavior.selector = "a.more_facets_link";
+ // Used for sort-by and per-page controls, hide the submit button
+ // and make the select auto-submit
+ Blacklight.do_select_submit = function() {
+ $(Blacklight.do_select_submit.selector).each(function() {
+ var select = $(this);
+ select.closest("form").find("input[type=submit]").hide();
+ select.bind("change", function() {
+ this.form.submit();
+ });
+ });
+ };
+ Blacklight.do_select_submit.selector = "form.sort select, form.per_page select";
+
+
Blacklight.do_lightbox_dialog = function() {
$("a.lightboxLink").ajaxyDialog({
chainAjaxySelector: false
@@ -98,11 +114,22 @@ $(document).ready(function() {
Blacklight.do_bookmark_toggle_behavior.selector = "form.bookmark_toggle";
Blacklight.do_folder_toggle_behavior = function() {
- $( Blacklight.do_folder_toggle_behavior.selector ).each(
- Blacklight.folder_submit_ajax
- );
+ $( Blacklight.do_folder_toggle_behavior.selector ).bl_checkbox_submit({
+ checked_label: "Selected",
+ unchecked_label: "Select",
+ css_class: "toggle_folder",
+ success: function(new_state) {
+
+ if (new_state) {
+ $("#folder_number").text(parseInt($("#folder_number").text()) + 1);
+ }
+ else {
+ $("#folder_number").text(parseInt($("#folder_number").text()) - 1);
+ }
+ }
+ });
};
- Blacklight.do_folder_toggle_behavior.selector = "form.addFolder, form.deleteFolder";
+ Blacklight.do_folder_toggle_behavior.selector = "form.folder_toggle";
Blacklight.do_facet_expand_contract_behavior = function() {
$( Blacklight.do_facet_expand_contract_behavior.selector ).each (
@@ -110,42 +137,7 @@ $(document).ready(function() {
);
}
Blacklight.do_facet_expand_contract_behavior.selector = '#facets h3';
-
- /* function for adding items to your folder with Ajax */
- //Behavior for making the select submit toggle be ajaxy, while
- //still being a submit button. Perhaps should be made into
- //an actual jQuery widget, but for now we just keep it here.
- //Perhaps should be changed to use checkbox style like Bookmarks.
- Blacklight.folder_submit_ajax = function() {
- var form = $(this);
- // We wrap the control on the folder page w/ a special element classed so we know not to
- // attach the jQuery function. The reason is we want the solr response to refresh so that
- // pagination as properly udpated.
- if(form.parent(".in_folder").length == 0){
- form.submit(function(){
- $.post(form.attr("action") + '?id=' + form.children("input[name=id]").attr("value"), function(data) {
- var title = form.attr("title");
- var folder_num, notice_text, new_form_action, new_button_text
- if(form.attr("action") == "/folder/destroy") {
- folder_num = parseInt($("#folder_number").text()) - 1;
- notice_text = title + " removed from your folder."
- new_form_action = "/folder";
- new_button_text = "Select"
- }else{
- folder_num = parseInt($("#folder_number").text()) + 1
- notice_text = title + " added to your folder.";
- new_form_action = "/folder/destroy";
- new_button_text = "Unselect";
- }
- $("#folder_number").text(folder_num);
- form.attr("action",new_form_action);
- form.children("input[type=submit]").attr("value",new_button_text);
- }, "json");
- return false;
- });
- }
- };
-
+
/* Behavior that makes facet limit headings in sidebar expand/contract
their contents. This is kind of fragile code targeted specifically
at how we currently render facet HTML, which is why I put it in a function
@@ -202,7 +194,10 @@ $(document).ready(function() {
unchecked_label: "Select",
progress_label: "Saving...",
//css_class is added to elements added, plus used for id base
- css_class: "toggle_my_kinda_form"
+ css_class: "toggle_my_kinda_form",
+ success: function(after_success_check_state) {
+ #optional callback
+ }
});
*/
(function($) {
@@ -212,13 +207,13 @@ $(document).ready(function() {
var options = $.extend({}, $.fn.bl_checkbox_submit.defaults, arg_opts);
- form = $(this);
- form.hide();
+ var form = $(this);
+ form.children().hide();
//We're going to use the existing form to actually send our add/removes
//This works conveneintly because the exact same action href is used
//for both bookmarks/$doc_id. But let's take out the irrelevant parts
//of the form to avoid any future confusion.
- form.find("input.bookmark_add, input.bookmark_remove").remove();
+ form.find("input[type=submit]").remove();
//View needs to set data-doc-id so we know a unique value
//for making DOM id
@@ -238,6 +233,7 @@ $(document).ready(function() {
function update_state_for(state) {
checkbox.attr("checked", state);
+ label.toggleClass("checked", state);
if (state) {
//Set the Rails hidden field that fakes an HTTP verb
//properly for current state action.
@@ -249,7 +245,7 @@ $(document).ready(function() {
}
}
- form.before(checkbox).before(" ").before(label);
+ form.append(checkbox).append(" ").append(label);
update_state_for(checked);
checkbox.click(function() {
@@ -266,11 +262,21 @@ $(document).ready(function() {
label.removeAttr("disabled");
checkbox.removeAttr("disabled");
},
- success: function() {
- checked = ! checked;
- update_state_for(checked);
- label.removeAttr("disabled");
- checkbox.removeAttr("disabled");
+ success: function(data, status, xhr) {
+ //if app isn't running at all, xhr annoyingly
+ //reports success with status 0.
+ if (xhr.status != 0) {
+ checked = ! checked;
+ update_state_for(checked);
+ label.removeAttr("disabled");
+ checkbox.removeAttr("disabled");
+ options.success.call(form, checked);
+ } else {
+ alert("Error");
+ update_state_for(checked);
+ label.removeAttr("disabled");
+ checkbox.removeAttr("disabled");
+ }
}
});
@@ -287,7 +293,8 @@ $(document).ready(function() {
unchecked_label: "",
progress_label: "Saving...",
//css_class is added to elements added, plus used for id base
- css_class: "bl_checkbox_submit"
+ css_class: "bl_checkbox_submit",
+ success: function() {} //callback
};
})(jQuery);
@@ -312,8 +319,7 @@ $(document).ready(function() {
options: {
extractTitleSelector: "h1, h2, h3, h4, h5",
chainAjaxySelector: "a:not([target]), form:not([target])",
- closeDialogSelector: "a.dialog-close",
- beforeDisplay: jQuery.noop
+ closeDialogSelector: "a.dialog-close"
},
_create: function() {
@@ -358,8 +364,14 @@ $(document).ready(function() {
$.ajax({
url: url,
dataType: "html",
- success: function(resp, status) {
- self._loadToDialog(resp);
+ success: function(resp, status, xhr) {
+ if (xhr.status != 0) {
+ self._loadToDialog(resp);
+ } else {
+ //stupid jquery calling this 'success', it's
+ //network unavailable.
+ self._displayFailure(url, xhr, status);
+ }
},
error: function(xhr, msg) {
self._displayFailure(url, xhr, msg);
@@ -380,8 +392,14 @@ $(document).ready(function() {
data: serialized,
type: form.attr("method").toUpperCase(),
dataType: "html",
- success: function(resp, status) {
- self._loadToDialog(resp);
+ success: function(resp, status, xhr) {
+ if (xhr.status != 0) {
+ self._loadToDialog(resp);
+ } else {
+ //stupid jquery calling this 'success', it's
+ //network unavailable.
+ self._displayFailure(url, xhr, status);
+ }
},
error: function(xhr, msg) {
self._displayFailure(actionUri, xhr, msg);
View
10 lib/generators/blacklight/templates/public/stylesheets/blacklight.css
@@ -243,16 +243,18 @@ font-weight:bold;
/* 'Document functions', Bookmark/Folder. Appear on both results/index and
detail/show views. */
-.documentFunctions {text-align:right; float: right; margin-left: 0.5em; margin-bottom: 0.5em;}
-.documentFunctions .deleteFolder, .documentFunctions .addFolder, .documentFunctions .bookmark_toggle {float:right;}
-label.toggle_bookmark {
+.documentFunctions { float: right; margin-left: 1em; margin-bottom: 0.5em;}
+.documentFunctions .folder_toggle, .documentFunctions .bookmark_toggle { display: inline; }
+label.toggle_bookmark, label.toggle_folder {
/* the ajaxy checkbox for toggle */
display: inline-block;
- min-width: 9em;
+ min-width: 8.5em;
text-align: left;
font-weight: inherit;
color: inherit;
}
+label.toggle_folder { min-width: 6em; }
+label.checked { font-weight: bold; }
/* Search Results */
View
1  lib/railties/blacklight.rake
@@ -4,6 +4,7 @@ namespace :blacklight do
# rake blacklight:delete_old_searches[days_old]
# example cron entry to delete searches older than 7 days at 2:00 AM every day:
# 0 2 * * * cd /path/to/your/app && /path/to/rake blacklight:delete_old_searches[7] RAILS_ENV=your_env
+ desc "Removes entries in the searches table that are older than the number of days given."
task :delete_old_searches, :days_old, :needs => :environment do |t, args|
Search.delete_old_searches(args[:days_old].to_i)
end
View
7 lib/railties/solr_marc.rake
@@ -128,9 +128,10 @@ def compute_arguments
end
def solrmarc_command_line(arguments)
- cmd = "java #{arguments[:solrmarc_mem_arg]} -jar #{arguments[:solrmarc_jar_path]} #{arguments[:config_properties_path]} #{arguments["MARC_FILE"]}"
-
- cmd += " -Dsolr.hosturl=#{arguments[:solr_url]}" unless arguments[:solr_url].blank?
+ cmd = "java #{arguments[:solrmarc_mem_arg]} "
+ cmd += " -Dsolr.hosturl=#{arguments[:solr_url]} " unless arguments[:solr_url].blank?
+ cmd += " -jar #{arguments[:solrmarc_jar_path]} #{arguments[:config_properties_path]} #{arguments["MARC_FILE"]}"
+ return cmd
end
View
99 spec/helpers/catalog_helper_spec.rb
@@ -0,0 +1,99 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+describe CatalogHelper do
+ include CatalogHelper
+
+ class MockResponse
+ attr_reader :total
+
+ def initialize args
+ @total = args[:total]
+ end
+ end
+
+# In case RSolr's duck typing diverages from WillPaginate::Collection
+ class MockCollection
+ attr_reader :current_page, :per_page
+
+ def initialize args
+ @current_page= args[:current_page] || 1
+ @total = args[:total] || 0
+ @per_page = args[:per_page] || 10
+ end
+
+ def previous_page
+ [@current_page - 1, 1].max
+ end
+
+ def next_page
+ @current_page + 1
+ end
+
+ def total_pages
+ (@total.to_f / @per_page).ceil
+ end
+
+ def size
+ return @per_page unless @current_page * @per_page > @total
+ @total % @per_page
+ end
+ end
+
+ def mock_collection args
+ current_page = args[:current_page] || 1
+ per_page = args[:per_page] || 10
+ total = args[:total]
+ arr = (1..total).to_a
+
+ page_results = WillPaginate::Collection.create(current_page, per_page, total) do |pager|
+ pager.replace(arr)
+ end
+ end
+
+ describe "page_entries_info" do
+ before(:all) do
+ end
+
+ it "with no results" do
+ @response = MockResponse.new :total => 0
+ @collection = MockCollection.new :total => @response.total
+
+ page_entries_info(@collection, { :entry_name => 'entry_name' }).should == "No entry_names found"
+ end
+
+ it "with a single result" do
+ @response = MockResponse.new :total => 1
+ @collection = MockCollection.new :total => @response.total
+
+ page_entries_info(@collection, { :entry_name => 'entry_name' }).should == "Displaying <b>1</b> entry_name"
+ end
+
+ it "with a single page of results" do
+ @response = MockResponse.new :total => 7
+ @collection = MockCollection.new :total => @response.total
+
+ page_entries_info(@collection, { :entry_name => 'entry_name' }).should == "Displaying <b>all 7</b> entry_names"
+ end
+
+ it "on the first page of multiple pages of results" do
+ @response = MockResponse.new :total => 15
+ @collection = MockCollection.new :total => @response.total, :per_page => 10
+
+ page_entries_info(@collection, { :entry_name => 'entry_name' }).should == "Displaying entry_names <b>1 - 10</b> of <b>15</b>"
+ end
+
+ it "on the second page of multiple pages of results" do
+ @response = MockResponse.new :total => 47
+ @collection = MockCollection.new :total => @response.total, :per_page => 10, :current_page => 2
+
+ page_entries_info(@collection, { :entry_name => 'entry_name' }).should == "Displaying entry_names <b>11 - 20</b> of <b>47</b>"
+ end
+
+ it "on the last page of results" do
+ @response = MockResponse.new :total => 47
+ @collection = MockCollection.new :total => @response.total, :per_page => 10, :current_page => 5
+
+ page_entries_info(@collection, { :entry_name => 'entry_name' }).should == "Displaying entry_names <b>41 - 47</b> of <b>47</b>"
+ end
+
+ end
+end
View
19 spec/views/catalog/_sms_form.html.erb_spec.rb
@@ -0,0 +1,19 @@
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
+
+describe "catalog/_sms_form.html.erb" do
+ before do
+ assigns[:documents] = [mock("document", :get => "fake_value")]
+ render :partial => "catalog/sms_form.html.erb"
+ end
+ describe "SMS form carrier select input" do
+ it "should have the prompt value first" do
+ response.should have_tag("option:nth-child(1)[value='']")
+ end
+ #it "should have other values alphabetized" do
+ # sorry can't figure out how to get rspec to do this
+ #end
+
+ end
+
+
+end
View
7 test_app/.gitignore
@@ -1,4 +1,3 @@
-.bundle
-db/*.sqlite3
-log/*.log
-tmp/
+*
+!features
+!spec
View
68 test_app/features/folder.feature
@@ -4,62 +4,62 @@ Feature: User Folder
I want to be able to store items in my folder
Scenario: Ensure "Add to Folder" form is present in search results
- Given I am on the home page
+ Given I am on the home page
When I fill in "q" with "history"
And I select "All Fields" from "search_field"
And I press "search"
- Then I should see an add to folder form
+ Then I should see an add to folder form
- Scenario: Ensure "Add to Folder" for is present on individual record
+ Scenario: Ensure "Add to Folder" for is present on individual record
Given I am on the document page for id 2007020969
- Then I should see an add to folder form
+ Then I should see an add to folder form
- Scenario: Adding an item to the folder should produce a status message
+ Scenario: Adding an item to the folder should produce a status message
Given I am on the home page
And I follow "English"
- And I add record 2008308175 to my folder
- Then I should see "Pluvial nectar of blessings successfully added to Folder"
- Scenario: Do not show "Add to Favorites" when not logged in
- Given I have record 2007020969 in my folder
- When I follow "Selected Items"
- Then I should not see "Add to Folder"
+ And I add record 2008308175 to my folder
+ Then I should see "Pluvial nectar of blessings successfully selected"
+ Scenario: Do not show "Add to Favorites" when not logged in
+ Given I have record 2007020969 in my folder
+ When I follow "Selected Items"
+ Then I should not see "Add to Folder"
- Scenario: Show "Add to Favorites" when logged in and viewing folder
+ Scenario: Show "Add to Favorites" when logged in and viewing folder
Given I am logged in as "user1"
- And I have record 2007020969 in my folder
+ And I have record 2007020969 in my folder
When I follow "Selected Items"
Then I should see "Add to Bookmarks"
- Scenario: Do multiple citations when the folder has multiple items
+ Scenario: Do multiple citations when the folder has multiple items
Given I have record 2007020969 in my folder
And I have record 2008308175 in my folder
- And I follow "Cite"
- Then I should see "Pluvial Nectar of Blessings : a Supplication to the Noble Lama Mahaguru Padmasambhava. Dharamsala: Library of Tibetan Works and Archives, 2002."
- And I should see "a Native American elder has her say : an oral history. 1st Atria Books hardcover ed. New York: Atria Books."
-
- Scenario: Make sure the folder page doesn't bomb if there is no search session
- Given I am on the folder page
- # That's all that is needed -- it will fail to render if it's not right
+ And I follow "Cite"
+ Then I should see "Pluvial Nectar of Blessings : a Supplication to the Noble Lama Mahaguru Padmasambhava. Dharamsala: Library of Tibetan Works and Archives, 2002."
+ And I should see "a Native American elder has her say : an oral history. 1st Atria Books hardcover ed. New York: Atria Books."
- Scenario: Don't show the tools if there are no items in the folder
- Given I am on the folder page
- Then I should not see the Folder tools
+ Scenario: Make sure the folder page doesn't bomb if there is no search session
+ Given I am on the folder page
+ # That's all that is needed -- it will fail to render if it's not right
+
+ Scenario: Don't show the tools if there are no items in the folder
+ Given I am on the folder page
+ Then I should not see the Folder tools
Scenario: Show the tools if there are items in the folder
Given I have record 2008308175 in my folder
- And I follow "Selected Items"
- Then I should see the Folder tools
+ And I follow "Selected Items"
+ Then I should see the Folder tools
- Scenario: Controls on the record view
- When I am on the document page for id 2008308175
- Then I should see an add to folder form
- Given I have record 2008308175 in my folder
- When I am on the document page for id 2008308175
- Then I should see a remove from folder form
+ Scenario: Controls on the record view
+ When I am on the document page for id 2008308175
+ Then I should see an add to folder form
+ Given I have record 2008308175 in my folder
+ When I am on the document page for id 2008308175
+ Then I should see a remove from folder form
- Scenario: Controls on the folder view
+ Scenario: Controls on the folder view
Given I have record 2008308175 in my folder
When I am on the folder page
Then I should see a remove from folder form
When I remove record 2008308175 from my folder
- Then I should not see the Folder tools
+ Then I should not see the Folder tools
View
6 test_app/spec/controllers/catalog_controller_spec.rb
@@ -372,6 +372,12 @@ def export_as_mock
post :send_email_record, :id => doc_id, :style => 'sms', :to => '555555555', :carrier => 'att'
request.flash[:error].should == "You must enter a valid 10 digit phone number"
end
+ it "should allow punctuation in phone number" do
+ pending() #CODEBASE-227
+ #post :send_email_record, :id => doc_id, :style => 'sms', :to => '(555) 555-5555', :carrier => 'att'
+ #response.flash[:error].should be_nil
+ #response.should redirect_to(catalog_path(doc_id))
+ end
it "should redirect back to the record upon success" do
pending() # see CODEBASE-227
#post :send_email_record, :id => doc_id, :style => 'sms', :to => '5555555555', :carrier => 'att'
View
16 test_app/spec/controllers/folder_controller_spec.rb
@@ -5,9 +5,9 @@
end
it "should add items to list" do
- get :create, :id =>"77826928"
+ get :update, :id =>"77826928"
session[:folder_document_ids].length.should == 1
- get :create, :id => "94120425"
+ get :update, :id => "94120425"
session[:folder_document_ids].length.should == 2
session[:folder_document_ids].should include("77826928")
get :index
@@ -15,25 +15,25 @@
assigns[:documents].first.should be_instance_of(SolrDocument)
end
it "should delete an item from list" do
- get :create, :id =>"77826928"
- get :create, :id => "94120425"
+ get :update, :id =>"77826928"
+ get :update, :id => "94120425"
get :destroy, :id =>"77826928"
session[:folder_document_ids].length.should == 1
session[:folder_document_ids].should_not include("77826928")
end
it "should clear list" do
- get :create, :id =>"77826928"
- get :create, :id => "94120425"
+ get :update, :id =>"77826928"
+ get :update, :id => "94120425"
get :clear
session[:folder_document_ids].length.should == 0
end
it "should generate flash messages for normal requests" do
- get :create, :id => "77826928"
+ get :update, :id => "77826928"
flash[:notice].length.should_not == 0
end
it "should clear flash messages after xhr request" do
- xhr :get, :create, :id => "77826928"
+ xhr :get, :update, :id => "77826928"
flash[:notice].should == nil
end
end
View
16 test_app/spec/helpers/solr_helper_spec.rb
@@ -754,25 +754,27 @@ def params
describe "facet_limit_for" do
it "should return specified value for facet_field specified" do
- @solr_helper.facet_limit_for("subject_facet").should == Blacklight.config[:facet][:limits]["subject_facet"]
+ @solr_helper.facet_limit_for("subject_topic_facet").should == Blacklight.config[:facet][:limits]["subject_topic_facet"]
end
it "@solr_helper.facet_limit_hash should return hash with key being facet_field and value being configured limit" do
@solr_helper.facet_limit_hash.should == Blacklight.config[:facet][:limits]
end
it "should handle no facet_limits in config" do
- Blacklight.config[:facet][:limits].has_key?("subject_facet").should be_true
- @solr_helper.facet_limit_for("subject_facet").should == 20
+ Blacklight.config[:facet][:field_names].include?("subject_topic_facet").should be_true
+ Blacklight.config[:facet][:limits].has_key?("subject_topic_facet").should be_true
+ @solr_helper.facet_limit_for("subject_topic_facet").should == 20
fl = Blacklight.config[:facet][:limits]
Blacklight.config[:facet][:limits] = nil
- @solr_helper.facet_limit_for("subject_facet").should be_nil
+ @solr_helper.facet_limit_for("subject_topic_facet").should be_nil
Blacklight.config[:facet][:limits] = fl
end
it "solr_search_params should handle no facet_limits in config" do
- Blacklight.config[:facet][:limits].has_key?("subject_facet").should be_true
- @solr_helper.solr_search_params[:"f.subject_facet.facet.limit"].should == 21
+ Blacklight.config[:facet][:field_names].include?("subject_topic_facet").should be_true
+ Blacklight.config[:facet][:limits].has_key?("subject_topic_facet").should be_true
+ @solr_helper.solr_search_params[:"f.subject_topic_facet.facet.limit"].should == 21
fl = Blacklight.config[:facet][:limits]
Blacklight.config[:facet][:limits] = nil
- @solr_helper.solr_search_params.has_key?(:"f.subject_facet.facet.limit").should be_false
+ @solr_helper.solr_search_params.has_key?(:"f.subject_topic_facet.facet.limit").should be_false
Blacklight.config[:facet][:limits] = fl
end
describe "for 'true' configured values" do
View
63 test_app/spec/lib/tasks/solr_marc_task_spec.rb
@@ -22,38 +22,39 @@ def capture_stdout
Rake.application.rake_require "lib/tasks/solr_marc"
Rake::Task.define_task(:environment)
end
-
-
- describe 'solr:marc:index_test_data' do
- it 'should print out usage using NOOP=true' do
- root = Rails.root
- ENV['NOOP'] = "true"
- o = capture_stdout do
- @rake['solr:marc:index_test_data'].invoke
- end
-
- o.should match(Regexp.escape("SolrMarc command that will be run:"))
- end
- end
-
- describe "solr:marc:index" do
- it "should produce proper java command" do
- # can NOT figure out how to actually run solr:marc:index and trap
- # it's backtick system call. So we'll run solr:marc:index:info and
- # just test it's dry run output
- ENV["MARC_FILE"] = "dummy.mrc"
- output = capture_stdout do
- @rake['solr:marc:index:info'].invoke
+
+
+ describe 'solr:marc:index_test_data' do
+ it 'should print out usage using NOOP=true' do
+ root = Rails.root
+ ENV['NOOP'] = "true"
+ o = capture_stdout do
+ @rake['solr:marc:index_test_data'].invoke
+ end
+
+ o.should match(Regexp.escape("SolrMarc command that will be run:"))
+ end
+ end
+
+ describe "solr:marc:index" do
+ it "should produce proper java command" do
+ # can NOT figure out how to actually run solr:marc:index and trap
+ # it's backtick system call. So we'll run solr:marc:index:info and
+ # just test it's dry run output
+ ENV["MARC_FILE"] = "dummy.mrc"
+ output = capture_stdout do
+ @rake['solr:marc:index:info'].invoke
+ end
+ output =~ /SolrMarc command that will be run:\n\s*\n\s*(.*)\n/
+ java_cmd = $1
+
+ java_cmd.should_not be_nil
+ java_cmd.should match "java -Xmx512m"
+ java_cmd.should match "-jar #{Rails.root}/solr_marc/SolrMarc.jar"
+ java_cmd.should match "#{Rails.root}/config/SolrMarc/config-test.properties dummy.mrc"
+ java_cmd.should match "-Dsolr.hosturl=http://127.0.0.1:[0-9]{4}/solr"
end
- output =~ /SolrMarc command that will be run:\n\s*\n\s*(.*)\n/
- java_cmd = $1
- java_cmd.should_not be_nil
- java_cmd.should match "java -Xmx512m -jar #{Rails.root}/solr_marc/SolrMarc.jar #{Rails.root}/config/SolrMarc/config-test.properties dummy.mrc -Dsolr.hosturl=http://127.0.0.1:[0-9]{4}/solr"
- end
-
+ end
end
-
-
-
end
View
20 test_app/spec/models/record_mailer_spec.rb
@@ -5,14 +5,15 @@
describe RecordMailer do
- before(:each) do
+
+ before do
@documents = []
@documents.push(stub_model(SolrDocument, :id => '123456', :to_marc => sample_marc, :[] => 'book'))
end
describe "email" do
before(:each) do
details = {:to => 'test@test.com', :message => "This is my message"}
- @email = RecordMailer.email_record(@documents,details,'projectblacklight.org','projectblacklight.org:3000')
+ @email = RecordMailer.email_record(@documents,details,'projectblacklight.org',{:host =>'projectblacklight.org', :protocol => 'https'})
end
it "should receive the TO paramater and send the email to that address" do
@email.to.should == ['test@test.com']
@@ -31,12 +32,17 @@
@email.body.should =~ /Author: Janetzky, Kurt/
@email.body.should =~ /projectblacklight.org:3000/
end
+ it "should use https URLs when protocol is set" do
+ details = {:to => 'test@test.com', :message => "This is my message"}
+ @https_email = RecordMailer.create_email_record(@documents,details,'projectblacklight.org',{:host =>'projectblacklight.org', :protocol => 'https'})
+ @https_email.body.should =~ %r|https://projectblacklight.org/|
+ end
end
describe "SMS" do
before(:each) do
details = {:to => '5555555555', :carrier => 'att'}
- @sms = RecordMailer.sms_record(@documents,details,'projectblacklight.org','projectblacklight.org:3000')
+ @sms = RecordMailer.sms_record(@documents,details,'projectblacklight.org',{:host =>'projectblacklight.org:3000'})
end
it "should create the correct TO address for the SMS email" do
@sms.to.should == ['5555555555@txt.att.net']
@@ -50,8 +56,12 @@
it "should print out the correct body" do
@sms.body.should =~ /The horn/
@sms.body.should =~ /by Janetzky, Kurt/
- @sms.body.should =~ /projectblacklight.org:300/
-
+ @sms.body.should =~ /projectblacklight.org:300/
+ end
+ it "should use https URL when protocol is set" do
+ details = {:to => '5555555555', :carrier => 'att'}
+ @https_sms = RecordMailer.create_sms_record(@documents,details,'projectblacklight.org',{:host =>'projectblacklight.org', :protocol => 'https'})
+ @https_sms.body.should =~ %r|https://projectblacklight.org/|
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.