Skip to content

Commit

Permalink
[webui] Some necessary adjustments to the testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
saschpe authored and coolo committed Jun 28, 2012
1 parent d820e21 commit de1dc9c
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/webui/app/views/project/new.html.erb
Expand Up @@ -15,7 +15,7 @@ end
</p>
<% end %>
<%= form_tag :action => 'save_new' do -%>
<%= form_tag :action => 'save_new', :method => 'post' do %>
<p>
<b>Project Name:</b><br/>
<% if @project_name %>
Expand All @@ -40,4 +40,4 @@ end
<%= check_box_tag :maintenance_project, false %>Create as maintenance project.
</p>
<p><%= submit_tag "Create Project" %></p>
<% end -%>
<% end %>
2 changes: 1 addition & 1 deletion src/webui/app/views/project/new_package.html.erb
Expand Up @@ -13,7 +13,7 @@
-->
<h2><%= @pagetitle %> for <%= @project.name %></h2>

<%= form_tag :controller => :package, :action => "save_new" do %>
<%= form_tag :controller => :package, :action => 'save_new', :method => 'post' do %>
<p>
<strong>Name:</strong><br/>
<%= text_field_tag 'name', @package_name, :size => 80 %><br/>
Expand Down
2 changes: 2 additions & 0 deletions src/webui/test/functional/application_controller_test.rb
Expand Up @@ -2,6 +2,8 @@

class ApplicationControllerTest < ActionController::IntegrationTest

include ApplicationHelper

def setup
end

Expand Down
78 changes: 48 additions & 30 deletions src/webui/test/test_helper.rb
@@ -1,41 +1,59 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require 'action_controller/integration'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

require "webrat"
require 'webrat'

Webrat.configure do |config|
config.mode = :rails
end

# Webrat Rails-3 compatibilty hack to be used instead of 'https://github.com/kalv/webrat.
# See http://groups.google.com/group/webrat/browse_thread/thread/fb5ff3fccd97f3df
# Webrat.configure do |config|
# config.mode = :rack
# end
# module Webrat
# class Session
# def current_host
# URI.parse(current_url).host || @custom_headers['Host'] || default_current_host
# end
# def default_current_host
# adapter.class==Webrat::RackAdapter ? 'example.org' : 'www.example.com'
# end
# end
# class Link
# def click_post(options = {})
# method = options[:method] || http_method
# return if href =~ /^#/ && method == :get
# @session.request_page(absolute_href, method, data)
# end
# end
# end

module ActionController
class IntegrationTest

# will provide a user without special permissions
def login_tom
post '/user/do_login', :username => 'tom', :password => 'thunder', :return_to_path => '/'
assert_redirected_to '/'
assert_equal "You are logged in now", @response.flash[:success]
end

def login_Iggy
post '/user/do_login', :username => 'Iggy', :password => 'asdfasdf', :return_to_path => '/'
assert_redirected_to '/'
assert_equal "You are logged in now", @response.flash[:success]
end

def login_adrian
post '/user/do_login', :username => 'adrian', :password => 'so_alone', :return_to_path => '/'
assert_redirected_to '/'
assert_equal "You are logged in now", @response.flash[:success]
end


def logout
post '/user/logout'
end

# will provide a user without special permissions
def login_tom
post '/user/do_login', :username => 'tom', :password => 'thunder', :return_to_path => '/'
assert_redirected_to '/'
assert_equal "You are logged in now", @request.flash[:success]
end

def login_Iggy
post '/user/do_login', :username => 'Iggy', :password => 'asdfasdf', :return_to_path => '/'
assert_redirected_to '/'
assert_equal "You are logged in now", @request.flash[:success]
end

def login_adrian
post '/user/do_login', :username => 'adrian', :password => 'so_alone', :return_to_path => '/'
assert_redirected_to '/'
assert_equal "You are logged in now", @request.flash[:success]
end

def logout
post '/user/logout'
end
end
end

3 changes: 1 addition & 2 deletions src/webui/test/unit/code_quality_test.rb
@@ -1,8 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + "/..") + "/test_helper"
require 'find'

RAILS_BASE_PATH = File.dirname(__FILE__) + '/../../'
RAILS_BASE_DIRS = ['app', 'db', 'config', 'lib', 'test', 'vendor/plugins'].map{|dir| RAILS_BASE_PATH + '/' + dir}
RAILS_BASE_DIRS = ['app', 'config', 'db', 'lib', 'test'].map{|dir| Rails.root.join(dir)}

class CodeQualityTest < ActiveSupport::TestCase
def setup
Expand Down

0 comments on commit de1dc9c

Please sign in to comment.