diff options
-rw-r--r-- | app/controllers/comment_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/track_controller.rb | 2 | ||||
-rw-r--r-- | app/models/comment.rb | 2 | ||||
-rw-r--r-- | app/models/info_request.rb | 2 | ||||
-rw-r--r-- | app/models/track_thing.rb | 2 | ||||
-rw-r--r-- | app/views/comment/_comment_form.html.erb | 2 | ||||
-rw-r--r-- | app/views/track/_tracking_links.html.erb | 2 | ||||
-rw-r--r-- | spec/controllers/track_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/track_thing_spec.rb | 2 |
10 files changed, 12 insertions, 12 deletions
diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index d4b17e9d2..cda56a211 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -38,7 +38,7 @@ class CommentController < ApplicationController if params[:comment] # XXX this check should theoretically be a validation rule in the model - @existing_comment = Comment.find_by_existing_comment(@info_request.id, params[:comment][:body]) + @existing_comment = Comment.find_existing(@info_request.id, params[:comment][:body]) else # Default to subscribing to request when first viewing form params[:subscribe_to_request] = true @@ -68,7 +68,7 @@ class CommentController < ApplicationController if params[:subscribe_to_request] @track_thing = TrackThing.create_track_for_request(@info_request) - @existing_track = TrackThing.find_by_existing_track(@user, @track_thing) + @existing_track = TrackThing.find_existing(@user, @track_thing) if @user && @info_request.user == @user # don't subscribe to own request! elsif !@existing_track diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index eac142fac..047fc7acf 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -189,7 +189,7 @@ class RequestController < ApplicationController end # TODO: I do think we should probably check for double submission of batch - # requests as we do in 'new' for ordinary requests with find_by_existing_request + # requests as we do in 'new' for ordinary requests with find_existing # TODO: Decide if we make batch requesters describe their undescribed requests # before being able to make a new batch request @@ -292,7 +292,7 @@ class RequestController < ApplicationController # XXX this check should theoretically be a validation rule in the # model, except we really want to pass @existing_request to the view so # it can link to it. - @existing_request = InfoRequest.find_by_existing_request(params[:info_request][:title], params[:info_request][:public_body_id], params[:outgoing_message][:body]) + @existing_request = InfoRequest.find_existing(params[:info_request][:title], params[:info_request][:public_body_id], params[:outgoing_message][:body]) # Create both FOI request and the first request message @info_request = InfoRequest.create_from_attributes(params[:info_request], diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 1123903f9..83e05ebbc 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -116,7 +116,7 @@ class TrackController < ApplicationController # Generic request tracker - set @track_thing before calling def track_set if @user - @existing_track = TrackThing.find_by_existing_track(@user, @track_thing) + @existing_track = TrackThing.find_existing(@user, @track_thing) if @existing_track flash[:notice] = _("You are already following updates about {{track_description}}", :track_description => @track_thing.params[:list_description]) return true diff --git a/app/models/comment.rb b/app/models/comment.rb index 75d37e04f..b4c099123 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -62,7 +62,7 @@ class Comment < ActiveRecord::Base end # When posting a new comment, use this to check user hasn't double submitted. - def Comment.find_by_existing_comment(info_request_id, body) + def Comment.find_existing(info_request_id, body) # XXX can add other databases here which have regexp_replace if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" # Exclude spaces from the body comparison using regexp_replace diff --git a/app/models/info_request.rb b/app/models/info_request.rb index b990f4b41..c95b7427e 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -387,7 +387,7 @@ public # repeated requests, say once a quarter for time information, then might need to do that. # XXX this *should* also check outgoing message joined to is an initial # request (rather than follow up) - def InfoRequest.find_by_existing_request(title, public_body_id, body) + def InfoRequest.find_existing(title, public_body_id, body) return InfoRequest.find(:first, :conditions => [ "title = ? and public_body_id = ? and outgoing_messages.body = ?", title, public_body_id, body ], :include => [ :outgoing_messages ] ) end diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index d5e1cdb75..d5dda7bb5 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -311,7 +311,7 @@ class TrackThing < ActiveRecord::Base end # When constructing a new track, use this to avoid duplicates / double posting - def TrackThing.find_by_existing_track(tracking_user, track) + def TrackThing.find_existing(tracking_user, track) if tracking_user.nil? return nil end diff --git a/app/views/comment/_comment_form.html.erb b/app/views/comment/_comment_form.html.erb index b78532768..6ca3f4c9f 100644 --- a/app/views/comment/_comment_form.html.erb +++ b/app/views/comment/_comment_form.html.erb @@ -3,7 +3,7 @@ <%= f.text_area :body, :rows => 10, :cols => 55 %> </p> - <% if !TrackThing.find_by_existing_track(@user, track_thing) && (!@user || @info_request.user != @user) %> + <% if !TrackThing.find_existing(@user, track_thing) && (!@user || @info_request.user != @user) %> <p> <%= check_box_tag 'subscribe_to_request', "1", params[:subscribe_to_request] ? true : false %> <label for="subscribe_to_request"><%= _('Email me future updates to this request') %></label> </p> diff --git a/app/views/track/_tracking_links.html.erb b/app/views/track/_tracking_links.html.erb index a3cd8fc60..5419ec605 100644 --- a/app/views/track/_tracking_links.html.erb +++ b/app/views/track/_tracking_links.html.erb @@ -1,6 +1,6 @@ <% if @user - existing_track = TrackThing.find_by_existing_track(@user, track_thing) + existing_track = TrackThing.find_existing(@user, track_thing) end %> diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 57d084f6b..40865d2b9 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -10,7 +10,7 @@ describe TrackController, "when making a new track on a request" do :tracking_user_id= => nil) TrackThing.stub!(:create_track_for_request).and_return(@track_thing) TrackThing.stub!(:create_track_for_search_query).and_return(@track_thing) - TrackThing.stub!(:find_by_existing_track).and_return(nil) + TrackThing.stub!(:find_existing).and_return(nil) InfoRequest.stub!(:find_by_url_title!) do |url_title| if url_title == "myrequest" @ir diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index 86d3c0cda..1c582564b 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -39,7 +39,7 @@ describe TrackThing, "when tracking changes" do it "will find existing tracks which are the same" do track_thing = TrackThing.create_track_for_search_query('fancy dog') - found_track = TrackThing.find_by_existing_track(users(:silly_name_user), track_thing) + found_track = TrackThing.find_existing(users(:silly_name_user), track_thing) found_track.should == @track_thing end |