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

40
TODO Normal file
View File

@ -0,0 +1,40 @@
CRITICAL
* Note translation mode. Click-and-drag to create a new note box.
* Note translation locking. When a post is locked, either prevent note edits by other users or notify them somehow. Should be timestamped so if someone fails to unlock a post it won't stay locked forever.
* Move help pages to the wiki.
IMPORTANT
* Require users to enter their password for some sensitive actions.
* Ability to change your account name.
* Ability to close your account.
* Protection against mass assignment.
* Eliminate password cookies.
* Replace parent/child relationships with anonymous pools. Each post would have a related posts field. This would drive the creation of an anonymous pool.
* Use a SSL cert for the login page.
* Ability to copy all notes from one post to another.
* Single post pagination mode.
* Ability to pull related tags from the wiki.
NICE TO HAVE
* Improved pool ordering interface.
* Ability to link users using dtext.
* Ability to highlight pools that have been updated since your last visit.
* Image similarity search integration.
* Ability to search post versions by tags.
* Tag autocompletion.
* Better formatting on comment/forum post preview so that the widths match the actual page.
* Searching for comments by tags.
* Face detection script (http://anime.udp.jp/face-detect)
* Use tf-idf to calculate tag relevance (http://en.wikipedia.org/wiki/Tf%E2%80%93idf)
* Upload progress meter (http://github.com/masterzen/nginx-upload-progress-module)
* Ajax upload form (http://valums.com/ajax-upload)
MAYBE
* Someone here mentioned the idea of tying tags to notes. I think this is the best way of clustering tags together on a post. I probably won't take a crack at this until after the initial deployment but it's something to keep in mind.

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>

View File

@ -164,5 +164,22 @@ module Danbooru
4 => "Character"
}
end
# Any custom code you want to insert into the default layout without
# having to modify the templates.
def custom_html_header_content
<<-EOS
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-86094-4");
pageTracker._trackPageview();
} catch(err) {}
</script>
EOS
end
end
end

View File

@ -1,3 +1,3 @@
ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable %w( feedback )
inflect.uncountable %w( user_feedback )
end

View File

@ -1,58 +1,56 @@
Danbooru::Application.routes.draw do |map|
# The priority is based upon order of creation:
# first created -> highest priority.
namespace :admin do
resources :users
end
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
resources :advertisements
resources :artists do
member do
put :revert
end
end
resources :artist_versions
resources :bans
resources :comments
resources :comment_votes
resources :dmails
resources :favorites
resources :forum_posts
resources :forum_topics
resources :janitor_trials
resources :jobs
resources :notes
resources :pools do
member do
put :revert
end
end
resources :pool_versions
resources :posts do
member do
put :revert
end
end
resources :post_moderation_details
resources :post_versions
resources :post_votes
resources :reports
resources :sessions
resources :tags
resources :tag_aliases
resources :tag_implications
resources :tag_subscriptions
resources :unapprovals
resources :users
resources :user_feedback
resources :wiki_pages do
member do
put :revert
end
end
resources :wiki_page_versions
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get :short
# post :toggle
# end
#
# collection do
# get :sold
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get :recent, :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => "welcome#index"
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
match "/site_map" => "static#site_map"
root :to => "post#index"
end

View File

@ -0,0 +1,3 @@
.blacklisted {
display: none !important;
}

View File

@ -7,6 +7,7 @@ end
Factory.define(:banned_user, :parent => :user) do |f|
f.is_banned true
f.ban {|x| x.association(:ban)}
end
Factory.define(:privileged_user, :parent => :user) do |f|

View File

@ -0,0 +1,8 @@
require 'test_helper'
class Admin::UsersControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class AdvertisementsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class ArtistVersionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class ArtistsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class BansControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class CommentVotesControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class CommentsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class DmailsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class FavoritesControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class ForumPostsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class ForumTopicsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class JanitorTrialsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class JobsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class NotesControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class PoolVersionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class PoolsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,90 @@
require File.join(File.dirname(__FILE__), %w(.. test_helper))
class PostControllerTest < ActionController::TestCase
context "A post controller" do
setup do
@users = {}
@users[:anon] = AnonymousUser.new
@users[:member] = Factory.create(:user)
@users[:banned] = Factory.create(:banned_user)
@users[:priv] = Factory.create(:privileged_user)
@users[:contrib] = Factory.create(:contributor_user)
@users[:janitor] = Factory.create(:janitor_user)
@users[:mod] = Factory.create(:moderator_user)
@users[:admin] = Factory.create(:admin_user)
end
teardown do
@users = nil
end
should "display the new post page" do
assert_authentication_fails(:new, :get, :anon)
assert_authentication_passes(:new, :get, :member)
end
should "create a post" do
post :create, {:post => {:source => "", :file => upload_jpeg("#{Rails.root}/test/files/test.jpg"), :tag_string => "hoge", :rating => "s"}}, {:user_id => @users[:member].id}
p = Post.last
assert_equal("hoge", p.tag_string)
assert_equal("jpg", p.file_ext)
assert_equal("s", p.rating)
assert_equal("uploader:#{@users[:member].name}", p.uploader_string)
assert_equal(true, File.exists?(p.file_path))
assert_equal(true, File.exists?(p.preview_path))
end
should "update a post" do
p1 = create_post("hoge")
put :update, {:post => {:tags => "moge", :rating => "Explicit"}, :id => p1.id}, {:user_id => 3}
p1.reload
assert_equal("moge", p1.cached_tags)
assert_equal("e", p1.rating)
assert_equal(2, p1.tag_history.size)
post :update, {:post => {:rating => "Safe"}, :id => p1.id}, {:user_id => 3}
assert_equal(3, p1.tag_history.size)
p1.update_attribute(:is_rating_locked, true)
post :update, {:post => {:rating => "Questionable"}, :id => p1.id}, {:user_id => 3}
p1.reload
assert_equal("s", p1.rating)
end
should "list posts" do
get :index, {}, {:user_id => 3}
assert_response :success
get :index, {:tags => "tag1"}, {:user_id => 3}
assert_response :success
get :index, {:format => "json"}, {:user_id => 3}
assert_response :success
get :index, {:format => "xml"}, {:user_id => 3}
assert_response :success
get :index, {:tags => "-tag1"}, {:user_id => 3}
assert_response :success
end
should "list posts through an atom feed" do
get :atom, {}, {:user_id => 3}
assert_response :success
get :atom, {:tags => "tag1"}, {:user_id => 3}
assert_response :success
end
should "display a post" do
get :show, {:id => 1}, {:user_id => 3}
assert_response :success
end
end
def test_popular
get :popular_by_day, {}, {:user_id => 3}
assert_response :success
end
end

View File

@ -0,0 +1,37 @@
require File.join(File.dirname(__FILE__), %w(.. test_helper))
class PostModerationDetailControllerTest < ActionController::TestCase
context "A post moderation detail controller" do
should "" do
ModQueuePost.destroy_all
p1 = create_post("hoge", :status => "pending")
p2 = create_post("hoge", :status => "active")
p3 = create_post("moge", :status => "active")
p2.flag!("sage", User.find(1))
p2.reload
assert_not_nil(p2.flag_detail)
get :moderate, {}, {:user_id => 1}
assert_response :success
get :moderate, {:query => "moge"}, {:user_id => 1}
assert_response :success
post :moderate, {:id => p1.id, :commit => "Approve"}, {:user_id => 1}
p1.reload
assert_equal("active", p1.status)
post :moderate, {:id => p3.id, :reason => "sage", :commit => "Delete"}, {:user_id => 1}
p3.reload
assert_equal("deleted", p3.status)
assert_not_nil(p3.flag_detail)
assert_equal("sage", p3.flag_detail.reason)
assert_equal(0, ModQueuePost.count)
post :moderate, {:id => "3", :commit => "Hide"}, {:user_id => 1}
assert_equal(1, ModQueuePost.count)
end
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class PostModerationDetailsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class PostVersionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class PostVotesControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class TagAliasesControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class TagImplicationsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class TagSubscriptionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class TagsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class UnapprovalsControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

Some files were not shown because too many files have changed in this diff Show More