]> git.openstreetmap.org Git - rails.git/commitdiff
Rename Trace#public to Trace#visible_to_all
authorTom Hughes <tom@compton.nu>
Thu, 24 Apr 2014 23:20:05 +0000 (00:20 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 4 Jul 2014 18:24:25 +0000 (19:24 +0100)
app/controllers/trace_controller.rb
app/models/trace.rb
test/controllers/trace_controller_test.rb
test/models/trace_test.rb

index 9c4a9d8bd18952816f0f267aacec2d378a3a61fc..e1553cbb0f7ca399ed2b86b6a1fbcb7bda247eca 100644 (file)
@@ -49,13 +49,13 @@ class TraceController < ApplicationController
       if @user
         @traces = Trace.visible_to(@user) #1
       else
-        @traces = Trace.public #2
+        @traces = Trace.visible_to_all #2
       end
     else
       if @user and @user == target_user
         @traces = @user.traces #3 (check vs user id, so no join + can't pick up non-public traces by changing name)
       else
-        @traces = target_user.traces.public #4
+        @traces = target_user.traces.visible_to_all #4
       end
     end
 
@@ -206,7 +206,7 @@ class TraceController < ApplicationController
   end
 
   def georss
-    @traces = Trace.public.visible
+    @traces = Trace.visible_to_all.visible
 
     if params[:display_name]
       @traces = @traces.joins(:user).where(:users => {:display_name => params[:display_name]})
index df66496a2601381bc103a4fdd6f3c6e9ed82691b..bf8d3731b8e7709a348a7b469fdeef0afd52a7e3 100644 (file)
@@ -7,7 +7,7 @@ class Trace < ActiveRecord::Base
 
   scope :visible, -> { where(:visible => true) }
   scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) }
-  scope :public, -> { where(:visibility => ["public", "identifiable"]) }
+  scope :visible_to_all, -> { where(:visibility => ["public", "identifiable"]) }
   scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
 
   validates_presence_of :user_id, :name, :timestamp
index 8cbc14b3164fd86342919505817cac618c7695da..68cacdce3695a9443e46459f7c5082a9c776be7e 100644 (file)
@@ -163,10 +163,10 @@ class TraceControllerTest < ActionController::TestCase
   # Check that the list of changesets is displayed
   def test_list
     get :list
-    check_trace_list Trace.public
+    check_trace_list Trace.visible_to_all
 
     get :list, :tag => "London"
-    check_trace_list Trace.tagged("London").public
+    check_trace_list Trace.tagged("London").visible_to_all
   end
 
   # Check that I can get mine
@@ -188,15 +188,15 @@ class TraceControllerTest < ActionController::TestCase
   def test_list_user
     # Test a user with no traces
     get :list, :display_name => users(:second_public_user).display_name
-    check_trace_list users(:second_public_user).traces.public
+    check_trace_list users(:second_public_user).traces.visible_to_all
 
     # Test a user with some traces - should see only public ones
     get :list, :display_name => users(:public_user).display_name
-    check_trace_list users(:public_user).traces.public
+    check_trace_list users(:public_user).traces.visible_to_all
 
     # Should still see only public ones when authenticated as another user
     get :list, {:display_name => users(:public_user).display_name}, {:user => users(:normal_user).id}
-    check_trace_list users(:public_user).traces.public
+    check_trace_list users(:public_user).traces.visible_to_all
 
     # Should see all traces when authenticated as the target user
     get :list, {:display_name => users(:public_user).display_name}, {:user => users(:public_user).id}
@@ -210,16 +210,16 @@ class TraceControllerTest < ActionController::TestCase
   # Check that the rss loads
   def test_rss
     get :georss, :format => :rss
-    check_trace_feed Trace.public
+    check_trace_feed Trace.visible_to_all
 
     get :georss, :tag => "London", :format => :rss
-    check_trace_feed Trace.tagged("London").public
+    check_trace_feed Trace.tagged("London").visible_to_all
 
     get :georss, :display_name => users(:public_user).display_name, :format => :rss
-    check_trace_feed users(:public_user).traces.public
+    check_trace_feed users(:public_user).traces.visible_to_all
 
     get :georss, :display_name => users(:public_user).display_name, :tag => "Birmingham", :format => :rss
-    check_trace_feed users(:public_user).traces.tagged("Birmingham").public
+    check_trace_feed users(:public_user).traces.tagged("Birmingham").visible_to_all
   end
 
   # Test viewing a trace
index 9ec40f18f40e75c610b101cef01c0a4c5d48388d..9f713924d1dc0128e9a526feed452b7d74e3cbf4 100644 (file)
@@ -27,8 +27,8 @@ class TraceTest < ActiveSupport::TestCase
     check_query(Trace.visible_to(3), [:public_trace_file, :identifiable_trace_file])
   end
 
-  def test_public
-    check_query(Trace.public, [:public_trace_file, :identifiable_trace_file, :deleted_trace_file])
+  def test_visible_to_all
+    check_query(Trace.visible_to_all, [:public_trace_file, :identifiable_trace_file, :deleted_trace_file])
   end
 
   def test_tagged