stubbed in blank controllers/helpers/functional tests

This commit is contained in:
albert
2010-03-10 18:21:43 -05:00
parent 836b59b1cd
commit ac98d7db37
137 changed files with 1349 additions and 58 deletions

View File

@@ -0,0 +1,2 @@
class Admin::UsersController < ApplicationController
end

View File

@@ -0,0 +1,22 @@
class AdvertisementsController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
def destroy
end
end

View File

@@ -1,3 +1,69 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_current_user
before_filter :initialize_cookies
protected
def access_denied
previous_url = params[:url] || request.request_uri
respond_to do |fmt|
fmt.html do
if request.get? && Rails.environment != "test"
redirect_to new_sessions_path(:url => previous_url), :notice => "Access denied"
else
redirect_to new_sessions_path, :notice => "Access denied"
end
end
fmt.xml do
render :xml => {:success => false, :reason => "access denied"}.to_xml(:root => "response"), :status => 403
end
fmt.json do
render :json => {:success => false, :reason => "access denied"}.to_json, :status => 403
end
end
end
def set_current_user
if @current_user == nil && session[:user_id]
@current_user = User.find_by_id(session[:user_id])
end
if @current_user == nil && params[:user]
@current_user = User.authenticate(params[:user][:name], params[:user][:password])
end
if @current_user == nil && params[:api]
@current_user = User.authenticate(params[:api][:key], params[:api][:hash])
end
if @current_user
if @current_user.is_banned? && @current_user.ban && @current_user.ban.expires_at < Time.now
@current_user.update_attribute(:is_banned, false)
Ban.destroy_all("user_id = #{@current_user.id}")
end
session[:user_id] = @current_user.id
else
@current_user = AnonymousUser.new
end
end
%w(banned privileged contributor janitor moderator admin).each do |level|
define_method("#{level}_only") do
if @current_user.__send__("is_#{level}?")
true
else
access_denied()
end
end
end
def initialize_cookies
if @current_user.is_anonymous?
cookies["blacklisted_tags"] = ""
else
cookies["blacklisted_tags"] = @current_user.blacklisted_tags
end
end
end

View File

@@ -0,0 +1,7 @@
class ArtistVersionsController < ApplicationController
def index
end
def show
end
end

View File

@@ -0,0 +1,25 @@
class ArtistsController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
def destroy
end
def revert
end
end

View File

@@ -0,0 +1,19 @@
class BansController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
end

View File

@@ -0,0 +1,7 @@
class CommentVotesController < ApplicationController
def create
end
def destroy
end
end

View File

@@ -0,0 +1,7 @@
class CommentsController < ApplicationController
def index
end
def update
end
end

View File

@@ -0,0 +1,13 @@
class DmailsController < ApplicationController
def new
end
def index
end
def show
end
def create
end
end

View File

@@ -0,0 +1,7 @@
class FavoritesController < ApplicationController
def create
end
def destroy
end
end

View File

@@ -0,0 +1,19 @@
class ForumPostsController < ApplicationController
def new
end
def edit
end
def show
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,22 @@
class ForumTopicsController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,19 @@
class JanitorTrialsController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
end

View File

@@ -0,0 +1,16 @@
class JobsController < ApplicationController
def edit
end
def index
end
def show
end
def destroy
end
def update
end
end

View File

@@ -0,0 +1,16 @@
class NotesController < ApplicationController
def index
end
def show
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,4 @@
class PoolVersionsController < ApplicationController
def index
end
end

View File

@@ -0,0 +1,25 @@
class PoolsController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
def destroy
end
def revert
end
end

View File

@@ -0,0 +1,13 @@
class PostModerationDetailsController < ApplicationController
def index
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,4 @@
class PostVersionsController < ApplicationController
def index
end
end

View File

@@ -0,0 +1,7 @@
class PostVotesController < ApplicationController
def create
end
def destroy
end
end

View File

@@ -0,0 +1,16 @@
class PostsController < ApplicationController
before_filter :member_only, :except => [:show, :index]
after_filter :save_recent_tags, :only => [:create, :update]
def index
end
def show
end
def update
end
def revert
end
end

View File

@@ -0,0 +1,10 @@
class SessionsController < ApplicationController
def new
end
def create
end
def destroy
end
end

View File

@@ -0,0 +1,19 @@
class TagAliasesController < ApplicationController
def new
end
def edit
end
def index
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,19 @@
class TagImplicationsController < ApplicationController
def new
end
def edit
end
def index
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,22 @@
class TagSubscriptionsController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,13 @@
class TagsController < ApplicationController
def edit
end
def index
end
def show
end
def update
end
end

View File

@@ -0,0 +1,13 @@
class UnapprovalsController < ApplicationController
def new
end
def index
end
def create
end
def destroy
end
end

View File

@@ -0,0 +1,10 @@
class UploadsController < ApplicationController
def new
end
def show
end
def create
end
end

View File

@@ -0,0 +1,19 @@
class UserFeedbackController < ApplicationController
def new
end
def edit
end
def index
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,22 @@
class UsersController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
def destroy
end
end

View File

@@ -0,0 +1,4 @@
class WikiPageVersionsController < ApplicationController
def index
end
end

View File

@@ -0,0 +1,25 @@
class WikiPagesController < ApplicationController
def new
end
def edit
end
def index
end
def show
end
def create
end
def update
end
def destroy
end
def revert
end
end

View File

@@ -0,0 +1,2 @@
module Admin::UsersHelper
end

View File

@@ -0,0 +1,2 @@
module AdvertisementsHelper
end

View File

@@ -1,2 +1,62 @@
module ApplicationHelper
def nav_link_to(text, options, html_options = nil)
if options[:controller] == params[:controller] || (%w(tag_alias tag_implication).include?(params[:controller]) && options[:controller] == "tag")
klass = "current-page"
else
klass = nil
end
%{<li class="#{klass}">} + fast_link_to(text, options, html_options) + "</li>"
end
def format_text(text, options = {})
DText.parse(text)
end
def id_to_color(id)
r = id % 255
g = (id >> 8) % 255
b = (id >> 16) % 255
"rgb(#{r}, #{g}, #{b})"
end
def tag_header(tags)
unless tags.blank?
'/' + Tag.scan_query(tags).map {|t| link_to(h(t.tr("_", " ")), posts_path(:tags => t)}.join("+")
end
end
def compact_time(time)
if time > Time.now.beginning_of_day
time.strftime("%H:%M")
elsif time > Time.now.beginning_of_year
time.strftime("%b %e")
else
time.strftime("%b %e, %Y")
end
end
def print_preview(post, options = {})
unless Danbooru.config.can_see_post?(post, @current_user)
return ""
end
options = {:blacklist => true}.merge(options)
blacklist = options[:blacklist] ? "blacklisted" : ""
width, height = post.preview_dimensions
image_id = options[:image_id]
image_id = %{id="#{h(image_id)}"} if image_id
title = "#{h(post.cached_tags)} rating:#{post.rating} score:#{post.score} uploader:#{h(post.uploader_name)}"
content_for(:blacklist) {"Post.register(#{post.to_json});\n"} if options[:blacklist]
%{
<span class="thumb #{blacklist}" id="p#{post.id}">
<a href="/posts/#{post.id}">
<img #{image_id} class="preview #{'flagged' if post.is_flagged?} #{'pending' if post.is_pending?}" src="#{post.preview_url}" title="#{title}" alt="#{title}" width="#{width}" height="#{height}">
</a>
</span>
}
end
end

View File

@@ -0,0 +1,2 @@
module ArtistVersionsHelper
end

View File

@@ -0,0 +1,2 @@
module ArtistsHelper
end

View File

@@ -0,0 +1,2 @@
module BansHelper
end

View File

@@ -0,0 +1,2 @@
module CommentVotesHelper
end

View File

@@ -0,0 +1,2 @@
module CommentsHelper
end

View File

@@ -0,0 +1,2 @@
module DmailsHelper
end

View File

@@ -0,0 +1,2 @@
module FavoritesHelper
end

View File

@@ -0,0 +1,2 @@
module ForumPostsHelper
end

View File

@@ -0,0 +1,2 @@
module ForumTopicsHelper
end

View File

@@ -0,0 +1,2 @@
module JanitorTrialsHelper
end

View File

@@ -0,0 +1,2 @@
module JobsHelper
end

View File

@@ -0,0 +1,2 @@
module NotesHelper
end

View File

@@ -0,0 +1,2 @@
module PoolVersionsHelper
end

View File

@@ -0,0 +1,2 @@
module PoolsHelper
end

View File

@@ -0,0 +1,2 @@
module PostHelper
end

View File

@@ -0,0 +1,2 @@
module PostModerationDetailsHelper
end

View File

@@ -0,0 +1,2 @@
module PostVersionsHelper
end

View File

@@ -0,0 +1,2 @@
module PostVotesHelper
end

View File

@@ -0,0 +1,2 @@
module SessionsHelper
end

View File

@@ -0,0 +1,2 @@
module TagAliasesHelper
end

View File

@@ -0,0 +1,2 @@
module TagImplicationsHelper
end

View File

@@ -0,0 +1,2 @@
module TagSubscriptionsHelper
end

View File

@@ -0,0 +1,2 @@
module TagsHelper
end

View File

@@ -0,0 +1,2 @@
module UnapprovalsHelper
end

View File

@@ -0,0 +1,2 @@
module UploadsHelper
end

View File

@@ -0,0 +1,2 @@
module UserFeedbackHelper
end

View File

@@ -0,0 +1,2 @@
module UsersHelper
end

View File

@@ -0,0 +1,2 @@
module WikiPageVersionsHelper
end

View File

@@ -0,0 +1,2 @@
module WikiPagesHelper
end

View File

@@ -117,6 +117,10 @@ class User < ActiveRecord::Base
self.is_privileged = true
end
end
def is_anonymous?
false
end
end
module EmailVerificationMethods
@@ -137,12 +141,19 @@ class User < ActiveRecord::Base
end
end
module BlacklistMethods
def blacklisted_tag_array
Tag.scan_query(blacklisted_tags)
end
end
include NameMethods
include PasswordMethods
extend AuthenticationMethods
include FavoriteMethods
include LevelMethods
include EmailVerificationMethods
include BlacklistMethods
def can_update?(object, foreign_key = :user_id)
is_moderator? || is_admin? || object.__send__(foreign_key) == id

View File

@@ -0,0 +1,2 @@
class PaginatorPresenter
end

View File

@@ -0,0 +1,76 @@
<!doctype html>
<html>
<head>
<title><%= yield :page_title %></title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="top" title="<%= Danbooru.config.app_name %>" href="/">
<%= auto_discovery_link_tag :atom, posts_path(:format => "atom", :tags => params[:tags]) %>
<%= stylesheet_link_tag "default" %>
<%= javascript_include_tag "application" %>
<%= Danbooru.config.custom_html_header_content %>
<%= yield :html_header_content %>
</head>
<body>
<div id="header">
<h2 id="site-title"><%= link_to(Danbooru.config.app_name, "/") %><%= tag_header(params[:tags]) %></h2>
<ul class="flat-list" id="nav">
<% if @current_user.is_member_or_higher? %>
<%= nav_link_to("My Account", user_path(@current_user)) %>
<% else %>
<%= nav_link_to("Login/Signup", new_session_path) %>
<% end %>
<%= nav_link_to("Posts", posts_path) %>
<%= nav_link_to("Comments", comments_path) %>
<%= nav_link_to("Notes", notes_path) %>
<%= nav_link_to("Artists", artists_path(:order => "date")) %>
<%= nav_link_to("Tags", tags_path(:order => "date")) %>
<%= nav_link_to("Pools", pools_path) %>
<%= nav_link_to("Wiki", wiki_page_path(:title => "help:home")) %>
<%= nav_link_to("Forum", forum_topics_path, :class => (@current_user.has_forum_been_updated? ? "forum-updated" : nil)) %>
<%= nav_link_to("&raquo;", site_map_help_path) %>
</ul>
<%= yield :secondary_nav_links %>
</div>
<% if flash[:notice] %>
<div id="notice"><%= h flash[:notice] %></div>
<% else %>
<div id="notice" style="display: none;"></div>
<% end %>
<% if @current_user.has_mail? %>
<div class="has-mail" id="has-mail-notice">
<%= link_to "You have mail", dmails_path %>
</div>
<% end %>
<% if !@current_user.is_privileged? %>
<div id="upgrade-account" style="display: none;">
<%= link_to "Upgrade your account for only $20", users_help_path %>
<%= link_to_function "No thanks", "$('upgrade-account').hide(); Cookie.put('hide-upgrade-account', '1', 7)", :id => "hide-upgrade-account-link" %>
</div>
<% end %>
<% if @current_user.is_banned? %>
<div id="ban-reason">
You have been banned.
<% if @current_user.ban %>
Reason: <%= h @current_user.ban.reason %>.
Expires: <%= @current_user.ban.expires_at.strftime('%Y-%m-%d') %>
<% end %>
</div>
<% end %>
<div id="content">
<%= yield :layout %>
</div>
<script type="text/javascript">
<%= yield :blacklist %>
Post.init_blacklisted();
Cookie.setup()
</script>
<%= yield :page_footer_content %>
</body>
</html>