--- /dev/null
+class AddUserIndexes < ActiveRecord::Migration
+ def change
+ add_index :oauth_tokens, [:user_id]
+ add_index :client_applications, [:user_id]
+ end
+end
-- PostgreSQL database dump
--
--- Dumped from database version 9.5.4
--- Dumped by pg_dump version 9.5.4
+-- Dumped from database version 9.5.6
+-- Dumped by pg_dump version 9.5.6
SET statement_timeout = 0;
SET lock_timeout = 0;
CREATE UNIQUE INDEX index_client_applications_on_key ON client_applications USING btree (key);
+--
+-- Name: index_client_applications_on_user_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_client_applications_on_user_id ON client_applications USING btree (user_id);
+
+
--
-- Name: index_diary_entry_subscriptions_on_diary_entry_id; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX index_oauth_tokens_on_token ON oauth_tokens USING btree (token);
+--
+-- Name: index_oauth_tokens_on_user_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_oauth_tokens_on_user_id ON oauth_tokens USING btree (user_id);
+
+
--
-- Name: index_user_blocks_on_user_id; Type: INDEX; Schema: public; Owner: -
--
INSERT INTO schema_migrations (version) VALUES ('20161011010929');
+INSERT INTO schema_migrations (version) VALUES ('20170222134109');
+
INSERT INTO schema_migrations (version) VALUES ('21');
INSERT INTO schema_migrations (version) VALUES ('22');
end
def test_getpresets
- [:public_user, :german_user].each do |id|
- user = users(id)
-
+ user_en_de = create(:normal_user, :languages => %w(en de))
+ user_de = create(:normal_user, :languages => %w(de))
+ [user_en_de, user_de].each do |user|
amf_content "getpresets", "/1", ["#{user.email}:test", ""]
post :amf_read
assert_response :success
assert_equal -1, result[0]
assert_match /must be logged in/, result[1]
- create(:user_block, :user => users(:blocked_user))
- amf_content "findgpx", "/1", [1, "blocked@openstreetmap.org:test"]
+ blocked_user = create(:normal_user)
+ create(:user_block, :user => blocked_user)
+ amf_content "findgpx", "/1", [1, "#{blocked_user.email}:test"]
post :amf_read
assert_response :success
amf_parse_response
end
def test_findgpx_by_id
- trace = create(:trace, :visibility => "private", :user => users(:public_user))
+ user = create(:normal_user)
+ trace = create(:trace, :visibility => "private", :user => user)
- amf_content "findgpx", "/1", [trace.id, "test@example.com:test"]
+ amf_content "findgpx", "/1", [trace.id, "#{user.email}:test"]
post :amf_read
assert_response :success
amf_parse_response
def test_new_form
# Now try again when logged in
- get :new, {}, { :user => create(:normal_user).id }
+ get :new, {}, { :user => create(:normal_user) }
assert_response :success
assert_select "title", :text => /New Diary Entry/, :count => 1
assert_select "div.content-heading", :count => 1 do
assert_equal "suspended", User.find(user.id).status
# Follow the redirect
- get :list, { :display_name => user.display_name }, { :user => user.id }
+ get :list, { :display_name => user.display_name }, { :user => user }
assert_response :redirect
assert_redirected_to :controller => :user, :action => :suspended
end
assert_redirected_to :controller => :user, :action => :login, :referer => "/user/#{URI.encode(entry.user.display_name)}/diary/#{entry.id}/edit"
# Verify that you get a not found error, when you pass a bogus id
- get :edit, { :display_name => entry.user.display_name, :id => 9999 }, { :user => entry.user.id }
+ get :edit, { :display_name => entry.user.display_name, :id => 9999 }, { :user => entry.user }
assert_response :not_found
assert_select "div.content-heading", :count => 1 do
assert_select "h2", :text => "No entry with the id: 9999", :count => 1
# Verify that you get redirected to view if you are not the user
# that created the entry
- get :edit, { :display_name => entry.user.display_name, :id => entry.id }, { :user => other_user.id }
+ get :edit, { :display_name => entry.user.display_name, :id => entry.id }, { :user => other_user }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => entry.user.display_name, :id => entry.id
# Now pass the id, and check that you can edit it, when using the same
# user as the person who created the entry
- get :edit, { :display_name => entry.user.display_name, :id => entry.id }, { :user => entry.user.id }
+ get :edit, { :display_name => entry.user.display_name, :id => entry.id }, { :user => entry.user }
assert_response :success
assert_select "title", :text => /Edit diary entry/, :count => 1
assert_select "div.content-heading", :count => 1 do
assert_redirected_to :action => :view, :display_name => entry.user.display_name, :id => entry.id
# Now check that the new data is rendered, when logged in
- get :view, { :display_name => entry.user.display_name, :id => entry.id }, { :user => entry.user.id }
+ get :view, { :display_name => entry.user.display_name, :id => entry.id }, { :user => entry.user }
assert_response :success
assert_template "diary_entry/view"
assert_select "title", :text => /Users' diaries | /, :count => 1
end
# and when not logged in as the user who wrote the entry
- get :view, { :display_name => entry.user.display_name, :id => entry.id }, { :user => entry.user.id }
+ get :view, { :display_name => entry.user.display_name, :id => entry.id }, { :user => entry.user }
assert_response :success
assert_template "diary_entry/view"
assert_select "title", :text => /Users' diaries | /, :count => 1
def test_edit_i18n
user = create(:normal_user)
diary_entry = create(:diary_entry, :language_code => "en", :user => user)
- get :edit, { :display_name => user.display_name, :id => diary_entry.id }, { :user => user.id }
+ get :edit, { :display_name => user.display_name, :id => diary_entry.id }, { :user => user }
assert_response :success
assert_select "span[class=translation_missing]", false, "Missing translation in edit diary entry"
end
assert_response :forbidden
# Verify that you get a not found error, when you pass a bogus id
- post :comment, { :display_name => entry.user.display_name, :id => 9999 }, { :user => other_user.id }
+ post :comment, { :display_name => entry.user.display_name, :id => 9999 }, { :user => other_user }
assert_response :not_found
assert_select "div.content-heading", :count => 1 do
assert_select "h2", :text => "No entry with the id: 9999", :count => 1
end
- post :subscribe, { :id => entry.id, :display_name => entry.user.display_name }, { :user => user.id }
+ post :subscribe, { :id => entry.id, :display_name => entry.user.display_name }, { :user => user }
# Now try an invalid comment with an empty body
assert_no_difference "ActionMailer::Base.deliveries.size" do
assert_no_difference "DiaryComment.count" do
assert_no_difference "entry.subscribers.count" do
- post :comment, { :display_name => entry.user.display_name, :id => entry.id, :diary_comment => { :body => "" } }, { :user => other_user.id }
+ post :comment, { :display_name => entry.user.display_name, :id => entry.id, :diary_comment => { :body => "" } }, { :user => other_user }
end
end
end
assert_difference "ActionMailer::Base.deliveries.size", entry.subscribers.count do
assert_difference "DiaryComment.count", 1 do
assert_difference "entry.subscribers.count", 1 do
- post :comment, { :display_name => entry.user.display_name, :id => entry.id, :diary_comment => { :body => "New comment" } }, { :user => other_user.id }
+ post :comment, { :display_name => entry.user.display_name, :id => entry.id, :diary_comment => { :body => "New comment" } }, { :user => other_user }
end
end
end
# Find the entry to comment on
entry = create(:diary_entry, :user => user)
- post :subscribe, { :id => entry.id, :display_name => entry.user.display_name }, { :user => user.id }
+ post :subscribe, { :id => entry.id, :display_name => entry.user.display_name }, { :user => user }
# Generate some spammy content
spammy_text = 1.upto(50).map { |n| "http://example.com/spam#{n}" }.join(" ")
# Try creating a spammy comment
assert_difference "ActionMailer::Base.deliveries.size", 1 do
assert_difference "DiaryComment.count", 1 do
- post :comment, { :display_name => entry.user.display_name, :id => entry.id, :diary_comment => { :body => spammy_text } }, { :user => other_user.id }
+ post :comment, { :display_name => entry.user.display_name, :id => entry.id, :diary_comment => { :body => spammy_text } }, { :user => other_user }
end
end
assert_response :redirect
assert_equal "suspended", User.find(other_user.id).status
# Follow the redirect
- get :list, { :display_name => user.display_name }, { :user => other_user.id }
+ get :list, { :display_name => user.display_name }, { :user => other_user }
assert_response :redirect
assert_redirected_to :controller => :user, :action => :suspended
assert_redirected_to :controller => :user, :action => :login, :referer => "/diary/friends"
# Try a list of diary entries for your friends when logged in
- get :list, { :friends => true }, { :user => user.id }
+ get :list, { :friends => true }, { :user => user }
check_diary_list diary_entry
- get :list, { :friends => true }, { :user => other_user.id }
+ get :list, { :friends => true }, { :user => other_user }
check_diary_list
end
assert_redirected_to :controller => :user, :action => :login, :referer => "/diary/nearby"
# Try a list of diary entries for nearby users when logged in
- get :list, { :nearby => true }, { :user => nearby_user.id }
+ get :list, { :nearby => true }, { :user => nearby_user }
check_diary_list diary_entry
- get :list, { :nearby => true }, { :user => user.id }
+ get :list, { :nearby => true }, { :user => user }
check_diary_list
end
assert_equal true, DiaryEntry.find(diary_entry.id).visible
# Now try as a normal user
- post :hide, { :display_name => user.display_name, :id => diary_entry.id }, { :user => user.id }
+ post :hide, { :display_name => user.display_name, :id => diary_entry.id }, { :user => user }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => user.display_name, :id => diary_entry.id
assert_equal true, DiaryEntry.find(diary_entry.id).visible
# Finally try as an administrator
- post :hide, { :display_name => user.display_name, :id => diary_entry.id }, { :user => create(:administrator_user, :status => "confirmed", :terms_seen => true).id }
+ post :hide, { :display_name => user.display_name, :id => diary_entry.id }, { :user => create(:administrator_user, :status => "confirmed", :terms_seen => true) }
assert_response :redirect
assert_redirected_to :action => :list, :display_name => user.display_name
assert_equal false, DiaryEntry.find(diary_entry.id).visible
assert_equal true, DiaryComment.find(diary_comment.id).visible
# Now try as a normal user
- post :hidecomment, { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }, { :user => user.id }
+ post :hidecomment, { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }, { :user => user }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => user.display_name, :id => diary_entry.id
assert_equal true, DiaryComment.find(diary_comment.id).visible
# Finally try as an administrator
- post :hidecomment, { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }, { :user => administrator_user.id }
+ post :hidecomment, { :display_name => user.display_name, :id => diary_entry.id, :comment => diary_comment.id }, { :user => administrator_user }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => user.display_name, :id => diary_entry.id
assert_equal false, DiaryComment.find(diary_comment.id).visible
diary_entry = create(:diary_entry, :user => user)
assert_difference "diary_entry.subscribers.count", 1 do
- post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user.id }
+ post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user }
end
assert_response :redirect
end
assert_response :forbidden
# bad diary id
- post :subscribe, { :id => 999111, :display_name => "username" }, { :user => other_user.id }
+ post :subscribe, { :id => 999111, :display_name => "username" }, { :user => other_user }
assert_response :not_found
# trying to subscribe when already subscribed
- post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user.id }
+ post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user }
assert_no_difference "diary_entry.subscribers.count" do
- post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user.id }
+ post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user }
end
end
diary_entry = create(:diary_entry, :user => user)
- post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user.id }
+ post :subscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user }
assert_difference "diary_entry.subscribers.count", -1 do
- post :unsubscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user.id }
+ post :unsubscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user }
end
assert_response :redirect
end
assert_response :forbidden
# bad diary id
- post :unsubscribe, { :id => 999111, :display_name => "username" }, { :user => other_user.id }
+ post :unsubscribe, { :id => 999111, :display_name => "username" }, { :user => other_user }
assert_response :not_found
# trying to unsubscribe when not subscribed
assert_no_difference "diary_entry.subscribers.count" do
- post :unsubscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user.id }
+ post :unsubscribe, { :id => diary_entry.id, :display_name => diary_entry.user.display_name }, { :user => other_user }
end
end
# Test the right editor gets used when the user hasn't set a preference
def test_edit_without_preference
- get :edit, nil, :user => users(:public_user).id
+ get :edit, nil, :user => users(:public_user)
assert_response :success
assert_template "edit"
assert_template :partial => "_#{DEFAULT_EDITOR}", :count => 1
user.preferred_editor = "id"
user.save!
- get :edit, nil, :user => user.id
+ get :edit, nil, :user => user
assert_response :success
assert_template "edit"
assert_template :partial => "_id", :count => 1
user.preferred_editor = "potlatch2"
user.save!
- get :edit, nil, :user => user.id
+ get :edit, nil, :user => user
assert_response :success
assert_template "edit"
assert_template :partial => "_potlatch2", :count => 1
user.preferred_editor = "potlatch"
user.save!
- get :edit, nil, :user => user.id
+ get :edit, nil, :user => user
assert_response :success
assert_template "edit"
assert_template :partial => "_potlatch", :count => 1
user.preferred_editor = "remote"
user.save!
- get :edit, nil, :user => user.id
+ get :edit, nil, :user => user
assert_response :success
assert_template "index"
end
# Test the right editor gets used when the URL has an override
def test_edit_with_override
- get :edit, { :editor => "id" }, { :user => users(:public_user).id }
+ get :edit, { :editor => "id" }, { :user => users(:public_user) }
assert_response :success
assert_template "edit"
assert_template :partial => "_id", :count => 1
- get :edit, { :editor => "potlatch2" }, { :user => users(:public_user).id }
+ get :edit, { :editor => "potlatch2" }, { :user => users(:public_user) }
assert_response :success
assert_template "edit"
assert_template :partial => "_potlatch2", :count => 1
- get :edit, { :editor => "potlatch" }, { :user => users(:public_user).id }
+ get :edit, { :editor => "potlatch" }, { :user => users(:public_user) }
assert_response :success
assert_template "edit"
assert_template :partial => "_potlatch", :count => 1
- get :edit, { :editor => "remote" }, { :user => users(:public_user).id }
+ get :edit, { :editor => "remote" }, { :user => users(:public_user) }
assert_response :success
assert_template "index"
end
user = users(:public_user)
node = current_nodes(:visible_node)
- get :edit, { :node => node.id }, { :user => user.id }
+ get :edit, { :node => node.id }, { :user => user }
assert_response :success
assert_template "edit"
assert_equal 1.0, assigns(:lat)
user = users(:public_user)
way = current_ways(:visible_way)
- get :edit, { :way => way.id }, { :user => user.id }
+ get :edit, { :way => way.id }, { :user => user }
assert_response :success
assert_template "edit"
assert_equal 3.0, assigns(:lat)
n.comments.create(:author_id => user.id)
end
- get :edit, { :note => note.id }, { :user => user.id }
+ get :edit, { :note => note.id }, { :user => user }
assert_response :success
assert_template "edit"
assert_equal 1.0, assigns(:lat)
user = users(:public_user)
gpx = create(:trace, :latitude => 1, :longitude => 1)
- get :edit, { :gpx => gpx.id }, { :user => user.id }
+ get :edit, { :gpx => gpx.id }, { :user => user }
assert_response :success
assert_template "edit"
assert_equal 1.0, assigns(:lat)
assert_response :redirect
assert_redirected_to :controller => :user, :action => :login, :referer => "/welcome"
- get :welcome, nil, :user => users(:public_user).id
+ get :welcome, nil, :user => users(:public_user)
assert_response :success
assert_template "welcome"
end
# Test the id frame
def test_id
- get :id, nil, :user => users(:public_user).id
+ get :id, nil, :user => users(:public_user)
assert_response :success
assert_template "id"
assert_template :layout => false
check_trace_list [trace_a]
# Should see more when we are logged in
- get :list, {}, { :user => users(:public_user).id }
+ get :list, {}, { :user => users(:public_user) }
check_trace_list [trace_d, trace_c, trace_b, trace_a]
# Again, we should see more when we are logged in
- get :list, { :tag => "London" }, { :user => users(:public_user).id }
+ get :list, { :tag => "London" }, { :user => users(:public_user) }
check_trace_list [trace_c, trace_a]
end
assert_redirected_to :controller => "user", :action => "login", :referer => "/traces/mine"
# Now try when logged in
- get :mine, {}, { :user => users(:public_user).id }
+ get :mine, {}, { :user => users(:public_user) }
assert_redirected_to :controller => "trace", :action => "list", :display_name => users(:public_user).display_name
# Fetch the actual list
- get :list, { :display_name => users(:public_user).display_name }, { :user => users(:public_user).id }
+ get :list, { :display_name => users(:public_user).display_name }, { :user => users(:public_user) }
check_trace_list [trace_b]
end
check_trace_list [trace_b]
# 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 }
+ get :list, { :display_name => users(:public_user).display_name }, { :user => users(:normal_user) }
check_trace_list [trace_b]
# Should see all traces when authenticated as the target user
- get :list, { :display_name => users(:public_user).display_name }, { :user => users(:public_user).id }
+ get :list, { :display_name => users(:public_user).display_name }, { :user => users(:public_user) }
check_trace_list [trace_c, trace_b]
# Should only see traces with the correct tag when a tag is specified
- get :list, { :display_name => users(:public_user).display_name, :tag => "London" }, { :user => users(:public_user).id }
+ get :list, { :display_name => users(:public_user).display_name, :tag => "London" }, { :user => users(:public_user) }
check_trace_list [trace_c]
# Should get an error if the user does not exist
check_trace_view public_trace_file
# Now with some other user, which should work since the trace is public
- get :view, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user).id }
+ get :view, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user) }
check_trace_view public_trace_file
# And finally we should be able to do it with the owner of the trace
- get :view, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user).id }
+ get :view, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user) }
check_trace_view public_trace_file
end
assert_redirected_to :action => :list
# Now with some other user, which should not work since the trace is anon
- get :view, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user).id }
+ get :view, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user) }
assert_response :redirect
assert_redirected_to :action => :list
# And finally we should be able to do it with the owner of the trace
- get :view, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user).id }
+ get :view, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user) }
check_trace_view anon_trace_file
end
assert_redirected_to :action => :list
# Now with some other user
- get :view, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+ get :view, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user) }
assert_response :redirect
assert_redirected_to :action => :list
# And finally we should not be able to view a deleted trace
- get :view, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user).id }
+ get :view, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user) }
assert_response :redirect
assert_redirected_to :action => :list
end
check_trace_data public_trace_file
# Now with some other user, which should work since the trace is public
- get :data, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user).id }
+ get :data, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user) }
check_trace_data public_trace_file
# And finally we should be able to do it with the owner of the trace
- get :data, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user).id }
+ get :data, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user) }
check_trace_data public_trace_file
end
assert_response :not_found
# Now with some other user, which shouldn't work since the trace is anon
- get :data, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user).id }
+ get :data, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user) }
assert_response :not_found
# And finally we should be able to do it with the owner of the trace
- get :data, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user).id }
+ get :data, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user) }
check_trace_data anon_trace_file
end
assert_response :not_found
# Now with a trace that has never existed
- get :data, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+ get :data, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user) }
assert_response :not_found
# Now with a trace that has been deleted
- get :data, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user).id }
+ get :data, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user) }
assert_response :not_found
end
check_trace_picture public_trace_file
# Now with some other user, which should work since the trace is public
- get :picture, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user).id }
+ get :picture, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user) }
check_trace_picture public_trace_file
# And finally we should be able to do it with the owner of the trace
- get :picture, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user).id }
+ get :picture, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user) }
check_trace_picture public_trace_file
end
assert_response :forbidden
# Now with some other user, which shouldn't work since the trace is anon
- get :picture, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user).id }
+ get :picture, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user) }
assert_response :forbidden
# And finally we should be able to do it with the owner of the trace
- get :picture, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user).id }
+ get :picture, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user) }
check_trace_picture anon_trace_file
end
assert_response :not_found
# Now with some other user, which should work since the trace is public
- get :picture, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+ get :picture, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user) }
assert_response :not_found
# And finally we should not be able to do it with a deleted trace
deleted_trace_file = create(:trace, :deleted)
- get :picture, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user).id }
+ get :picture, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user) }
assert_response :not_found
end
check_trace_icon public_trace_file
# Now with some other user, which should work since the trace is public
- get :icon, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user).id }
+ get :icon, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user) }
check_trace_icon public_trace_file
# And finally we should be able to do it with the owner of the trace
- get :icon, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user).id }
+ get :icon, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user) }
check_trace_icon public_trace_file
end
assert_response :forbidden
# Now with some other user, which shouldn't work since the trace is anon
- get :icon, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user).id }
+ get :icon, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:normal_user) }
assert_response :forbidden
# And finally we should be able to do it with the owner of the trace
- get :icon, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user).id }
+ get :icon, { :display_name => users(:public_user).display_name, :id => anon_trace_file.id }, { :user => users(:public_user) }
check_trace_icon anon_trace_file
end
assert_response :not_found
# Now with some other user
- get :icon, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+ get :icon, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user) }
assert_response :not_found
# And finally we should not be able to do it with a deleted trace
deleted_trace_file = create(:trace, :deleted)
- get :icon, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user).id }
+ get :icon, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user) }
assert_response :not_found
end
# Now authenticated as a user with gps.trace.visibility set
create(:user_preference, :user => users(:public_user), :k => "gps.trace.visibility", :v => "identifiable")
- get :create, {}, { :user => users(:public_user).id }
+ get :create, {}, { :user => users(:public_user) }
assert_response :success
assert_template :create
assert_select "select#trace_visibility option[value=identifiable][selected]", 1
# Now authenticated as a user with gps.trace.public set
create(:user_preference, :user => users(:second_public_user), :k => "gps.trace.public", :v => "default")
- get :create, {}, { :user => users(:second_public_user).id }
+ get :create, {}, { :user => users(:second_public_user) }
assert_response :success
assert_template :create
assert_select "select#trace_visibility option[value=public][selected]", 1
# Now authenticated as a user with no preferences
- get :create, {}, { :user => users(:normal_user).id }
+ get :create, {}, { :user => users(:normal_user) }
assert_response :success
assert_template :create
assert_select "select#trace_visibility option[value=private][selected]", 1
# Now authenticated
create(:user_preference, :user => users(:public_user), :k => "gps.trace.visibility", :v => "identifiable")
assert_not_equal "trackable", users(:public_user).preferences.where(:k => "gps.trace.visibility").first.v
- post :create, { :trace => { :gpx_file => file, :description => "New Trace", :tagstring => "new,trace", :visibility => "trackable" } }, { :user => users(:public_user).id }
+ post :create, { :trace => { :gpx_file => file, :description => "New Trace", :tagstring => "new,trace", :visibility => "trackable" } }, { :user => users(:public_user) }
assert_response :redirect
assert_redirected_to :action => :list, :display_name => users(:public_user).display_name
assert_match /file has been uploaded/, flash[:notice]
assert_redirected_to :controller => :user, :action => :login, :referer => trace_edit_path(:display_name => users(:normal_user).display_name, :id => public_trace_file.id)
# Now with some other user, which should fail
- get :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user).id }
+ get :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user) }
assert_response :forbidden
# Now with a trace which doesn't exist
- get :edit, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+ get :edit, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user) }
assert_response :not_found
# Now with a trace which has been deleted
- get :edit, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user).id }
+ get :edit, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user) }
assert_response :not_found
# Finally with a trace that we are allowed to edit
- get :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user).id }
+ get :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user) }
assert_response :success
end
assert_response :forbidden
# Now with some other user, which should fail
- post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user).id }
+ post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user) }
assert_response :forbidden
# Now with a trace which doesn't exist
- post :edit, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+ post :edit, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user) }
assert_response :not_found
# Now with a trace which has been deleted
- post :edit, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user).id }
+ post :edit, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user) }
assert_response :not_found
# Finally with a trace that we are allowed to edit
- post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user).id }
+ post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user) }
assert_response :success
end
assert_response :forbidden
# Now with some other user, which should fail
- post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id, :trace => new_details }, { :user => users(:public_user).id }
+ post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id, :trace => new_details }, { :user => users(:public_user) }
assert_response :forbidden
# Now with a trace which doesn't exist
- post :edit, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id, :trace => new_details }
+ post :edit, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user), :trace => new_details }
assert_response :not_found
# Now with a trace which has been deleted
- post :edit, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id, :trace => new_details }, { :user => users(:public_user).id }
+ post :edit, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id, :trace => new_details }, { :user => users(:public_user) }
assert_response :not_found
# Finally with a trace that we are allowed to edit
- post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id, :trace => new_details }, { :user => users(:normal_user).id }
+ post :edit, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id, :trace => new_details }, { :user => users(:normal_user) }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name
trace = Trace.find(public_trace_file.id)
assert_response :forbidden
# Now with some other user, which should fail
- post :delete, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user).id }
+ post :delete, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:public_user) }
assert_response :forbidden
# Now with a trace which doesn't exist
- post :delete, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user).id }
+ post :delete, { :display_name => users(:public_user).display_name, :id => 0 }, { :user => users(:public_user) }
assert_response :not_found
# Now with a trace has already been deleted
- post :delete, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user).id }
+ post :delete, { :display_name => users(:public_user).display_name, :id => deleted_trace_file.id }, { :user => users(:public_user) }
assert_response :not_found
# Finally with a trace that we are allowed to delete
- post :delete, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user).id }
+ post :delete, { :display_name => users(:normal_user).display_name, :id => public_trace_file.id }, { :user => users(:normal_user) }
assert_response :redirect
assert_redirected_to :action => :list, :display_name => users(:normal_user).display_name
trace = Trace.find(public_trace_file.id)
assert_redirected_to :controller => :user, :action => "login", :referer => "/user/test/account"
# Make sure that you are blocked when not logged in as the right user
- get :account, { :display_name => user.display_name }, { :user => users(:public_user).id }
+ get :account, { :display_name => user.display_name }, { :user => users(:public_user) }
assert_response :forbidden
# Make sure we get the page when we are logged in as the right user
# Updating the description should work
user.description = "new description"
- post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select "div#errorExplanation", false
# Changing to a invalid editor should fail
user.preferred_editor = "unknown"
- post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select ".notice", false
# Changing to a valid editor should work
user.preferred_editor = "potlatch2"
- post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select "div#errorExplanation", false
# Changing to the default editor should work
user.preferred_editor = "default"
- post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select "div#errorExplanation", false
# Changing to an uploaded image should work
image = Rack::Test::UploadedFile.new("test/gpx/fixtures/a.gif", "image/gif")
- post :account, { :display_name => user.display_name, :image_action => "new", :user => user.attributes.merge(:image => image) }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :image_action => "new", :user => user.attributes.merge(:image => image) }, { :user => user }
assert_response :success
assert_template :account
assert_select "div#errorExplanation", false
assert_select "form#accountForm > fieldset > div.form-row.accountImage input[name=image_action][checked][value=?]", "keep"
# Changing to a gravatar image should work
- post :account, { :display_name => user.display_name, :image_action => "gravatar", :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :image_action => "gravatar", :user => user.attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select "div#errorExplanation", false
assert_select "form#accountForm > fieldset > div.form-row.accountImage input[name=image_action][checked][value=?]", "gravatar"
# Removing the image should work
- post :account, { :display_name => user.display_name, :image_action => "delete", :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :image_action => "delete", :user => user.attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select "div#errorExplanation", false
assert_select "form#accountForm > fieldset > div.form-row.accountImage input[name=image_action][checked]", false
# Adding external authentication should redirect to the auth provider
- post :account, { :display_name => user.display_name, :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes.merge(:auth_provider => "openid", :auth_uid => "gmail.com") }, { :user => user }
assert_response :redirect
assert_redirected_to auth_path(:provider => "openid", :openid_url => "https://www.google.com/accounts/o8/id", :origin => "/user/#{user.display_name}/account")
# Changing name to one that exists should fail
new_attributes = user.attributes.dup.merge(:display_name => users(:public_user).display_name)
- post :account, { :display_name => user.display_name, :user => new_attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => new_attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select ".notice", false
# Changing name to one that exists should fail, regardless of case
new_attributes = user.attributes.dup.merge(:display_name => users(:public_user).display_name.upcase)
- post :account, { :display_name => user.display_name, :user => new_attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => new_attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select ".notice", false
# Changing name to one that doesn't exist should work
new_attributes = user.attributes.dup.merge(:display_name => "new tester")
- post :account, { :display_name => user.display_name, :user => new_attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => new_attributes }, { :user => user }
assert_response :success
assert_template :account
assert_select "div#errorExplanation", false
# Changing email to one that exists should fail
user.new_email = users(:public_user).email
assert_no_difference "ActionMailer::Base.deliveries.size" do
- post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user }
end
assert_response :success
assert_template :account
# Changing email to one that exists should fail, regardless of case
user.new_email = users(:public_user).email.upcase
assert_no_difference "ActionMailer::Base.deliveries.size" do
- post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user }
end
assert_response :success
assert_template :account
# Changing email to one that doesn't exist should work
user.new_email = "new_tester@example.com"
assert_difference "ActionMailer::Base.deliveries.size", 1 do
- post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user.id }
+ post :account, { :display_name => user.display_name, :user => user.attributes }, { :user => user }
end
assert_response :success
assert_template :account
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# When logged in a GET should get a confirmation page
- get :make_friend, { :display_name => friend.display_name }, { :user => user.id }
+ get :make_friend, { :display_name => friend.display_name }, { :user => user }
assert_response :success
assert_template :make_friend
assert_select "form" do
# When logged in a POST should add the friendship
assert_difference "ActionMailer::Base.deliveries.size", 1 do
- post :make_friend, { :display_name => friend.display_name }, { :user => user.id }
+ post :make_friend, { :display_name => friend.display_name }, { :user => user }
end
assert_redirected_to user_path(:display_name => friend.display_name)
assert_match /is now your friend/, flash[:notice]
# A second POST should report that the friendship already exists
assert_no_difference "ActionMailer::Base.deliveries.size" do
- post :make_friend, { :display_name => friend.display_name }, { :user => user.id }
+ post :make_friend, { :display_name => friend.display_name }, { :user => user }
end
assert_redirected_to user_path(:display_name => friend.display_name)
assert_match /You are already friends with/, flash[:warning]
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# The GET should preserve any referer
- get :make_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user.id }
+ get :make_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user }
assert_response :success
assert_template :make_friend
assert_select "form" do
# When logged in a POST should add the friendship and refer us
assert_difference "ActionMailer::Base.deliveries.size", 1 do
- post :make_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user.id }
+ post :make_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user }
end
assert_redirected_to "/test"
assert_match /is now your friend/, flash[:notice]
def test_make_friend_unkown_user
# Should error when a bogus user is specified
- get :make_friend, { :display_name => "No Such User" }, { :user => users(:normal_user).id }
+ get :make_friend, { :display_name => "No Such User" }, { :user => users(:normal_user) }
assert_response :not_found
assert_template :no_such_user
end
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# When logged in a GET should get a confirmation page
- get :remove_friend, { :display_name => friend.display_name }, { :user => user.id }
+ get :remove_friend, { :display_name => friend.display_name }, { :user => user }
assert_response :success
assert_template :remove_friend
assert_select "form" do
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# When logged in a POST should remove the friendship
- post :remove_friend, { :display_name => friend.display_name }, { :user => user.id }
+ post :remove_friend, { :display_name => friend.display_name }, { :user => user }
assert_redirected_to user_path(:display_name => friend.display_name)
assert_match /was removed from your friends/, flash[:notice]
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# A second POST should report that the friendship does not exist
- post :remove_friend, { :display_name => friend.display_name }, { :user => user.id }
+ post :remove_friend, { :display_name => friend.display_name }, { :user => user }
assert_redirected_to user_path(:display_name => friend.display_name)
assert_match /is not one of your friends/, flash[:error]
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# The GET should preserve any referer
- get :remove_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user.id }
+ get :remove_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user }
assert_response :success
assert_template :remove_friend
assert_select "form" do
assert Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
# When logged in a POST should remove the friendship and refer
- post :remove_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user.id }
+ post :remove_friend, { :display_name => friend.display_name, :referer => "/test" }, { :user => user }
assert_redirected_to "/test"
assert_match /was removed from your friends/, flash[:notice]
assert_nil Friend.where(:user_id => user.id, :friend_user_id => friend.id).first
def test_remove_friend_unkown_user
# Should error when a bogus user is specified
- get :remove_friend, { :display_name => "No Such User" }, { :user => users(:normal_user).id }
+ get :remove_friend, { :display_name => "No Such User" }, { :user => users(:normal_user) }
assert_response :not_found
assert_template :no_such_user
end
assert_redirected_to :action => :login, :referer => set_status_user_path(:status => "suspended")
# Now try as a normal user
- get :set_status, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:normal_user).id }
+ get :set_status, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:normal_user) }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name
# Finally try as an administrator
- get :set_status, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:administrator_user).id }
+ get :set_status, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:administrator_user) }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name
assert_equal "suspended", User.find(users(:normal_user).id).status
assert_redirected_to :action => :login, :referer => delete_user_path(:status => "suspended")
# Now try as a normal user
- get :delete, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:normal_user).id }
+ get :delete, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:normal_user) }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name
# Finally try as an administrator
- get :delete, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:administrator_user).id }
+ get :delete, { :display_name => users(:normal_user).display_name, :status => "suspended" }, { :user => users(:administrator_user) }
assert_response :redirect
assert_redirected_to :action => :view, :display_name => users(:normal_user).display_name