- check_query(Trace.visible_to(1), [:public_trace_file, :identifiable_trace_file])
- check_query(Trace.visible_to(2), [:public_trace_file, :anon_trace_file, :trackable_trace_file, :identifiable_trace_file])
- 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])
+ first_user = create(:user)
+ second_user = create(:user)
+ third_user = create(:user)
+ fourth_user = create(:user)
+ public_trace_file = create(:trace, :visibility => "public", :user => first_user)
+ anon_trace_file = create(:trace, :visibility => "private", :user => second_user)
+ identifiable_trace_file = create(:trace, :visibility => "identifiable", :user => first_user)
+ pending_trace_file = create(:trace, :visibility => "public", :user => second_user, :inserted => false)
+ trackable_trace_file = create(:trace, :visibility => "trackable", :user => second_user)
+ _other_trace_file = create(:trace, :visibility => "private", :user => third_user)
+
+ check_query(Trace.visible_to(first_user), [
+ public_trace_file, identifiable_trace_file, pending_trace_file
+ ])
+ check_query(Trace.visible_to(second_user), [
+ public_trace_file, anon_trace_file, trackable_trace_file,
+ identifiable_trace_file, pending_trace_file
+ ])
+ check_query(Trace.visible_to(fourth_user), [
+ public_trace_file, identifiable_trace_file, pending_trace_file
+ ])
+ end
+
+ def test_visible_to_all
+ public_trace_file = create(:trace, :visibility => "public")
+ _private_trace_file = create(:trace, :visibility => "private")
+ identifiable_trace_file = create(:trace, :visibility => "identifiable")
+ _trackable_trace_file = create(:trace, :visibility => "trackable")
+ deleted_trace_file = create(:trace, :deleted, :visibility => "public")
+ pending_trace_file = create(:trace, :visibility => "public", :inserted => false)
+
+ check_query(Trace.visible_to_all, [
+ public_trace_file, identifiable_trace_file,
+ deleted_trace_file, pending_trace_file
+ ])