Navigation Menu

Skip to content

Commit

Permalink
[#4199] Require a logged in user to Join Projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
edavis10 committed Jun 23, 2010
1 parent e47e6c1 commit c8b3f7c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/join_project_requests_controller.rb
@@ -1,5 +1,6 @@
class JoinProjectRequestsController < ApplicationController
unloadable
before_filter :require_login
before_filter :find_project, :except => [:index]
before_filter :authorize, :except => [:index]
before_filter :authorize_global, :only => [:index]
Expand Down
1 change: 1 addition & 0 deletions app/controllers/join_projects_controller.rb
@@ -1,5 +1,6 @@
class JoinProjectsController < ApplicationController
unloadable
before_filter :require_login
before_filter :find_project
before_filter :authorize

Expand Down
13 changes: 13 additions & 0 deletions test/functional/join_project_requests_controller_test.rb
Expand Up @@ -138,6 +138,19 @@ class JoinProjectRequestsControllerTest < ActionController::TestCase
assert_nil ProjectJoinRequest.find_by_user_id_and_project_id(@user.id, @project.id)
end
end

context "with no logged in user" do
setup do
setup_plugin_configuration
@request.session[:user_id] = nil
@project = Project.generate!(:project_subscription => 'none', :is_public => true)

post :create, :project_id => @project.to_param
end

should_respond_with :redirect
should_redirect_to("login") { {:controller => 'account', :action => 'login'} }
end
end

context "on POST to :create on an unauthorized project" do
Expand Down
13 changes: 13 additions & 0 deletions test/functional/join_projects_controller_test.rb
Expand Up @@ -78,6 +78,19 @@ class JoinProjectsControllerTest < ActionController::TestCase
assert !@user.member_of?(@project), "Membership created"
end
end

context "with no logged in user" do
setup do
setup_plugin_configuration
@project = Project.generate!(:project_subscription => 'self-subscribe')

post :create, :project_id => @project.to_param
end

should_respond_with :redirect
should_redirect_to("login") { {:controller => 'account', :action => 'login'} }
end

end

context "on POST to :create on an unauthorized project" do
Expand Down

0 comments on commit c8b3f7c

Please sign in to comment.