forked from e621ng/e621ng
add tag impl functional test
This commit is contained in:
parent
d6f7ccd7ef
commit
ee9aca973f
@ -1,19 +1,37 @@
|
||||
class TagImplicationsController < ApplicationController
|
||||
before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy]
|
||||
respond_to :html, :xml, :json
|
||||
|
||||
def new
|
||||
@tag_implication = TagImplication.new
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
|
||||
def edit
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
|
||||
def index
|
||||
@search = TagImplication.search(params[:search])
|
||||
@tag_implicationes = @search.paginate(:page => params[:page])
|
||||
respond_with(@tag_implicationes)
|
||||
end
|
||||
|
||||
def create
|
||||
@tag_implication = TagImplication.create(params[:tag_implication])
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
|
||||
def update
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
@tag_implication.update_attributes(params[:tag_implication])
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@tag_implication = TagImplication.find(params[:id])
|
||||
@tag_implication.destroy
|
||||
respond_with(@tag_implication)
|
||||
end
|
||||
end
|
||||
|
0
app/views/tag_implications/edit.html.erb
Normal file
0
app/views/tag_implications/edit.html.erb
Normal file
0
app/views/tag_implications/index.html.erb
Normal file
0
app/views/tag_implications/index.html.erb
Normal file
0
app/views/tag_implications/new.html.erb
Normal file
0
app/views/tag_implications/new.html.erb
Normal file
@ -1,2 +1,4 @@
|
||||
Factory.define(:tag_implication) do |f|
|
||||
f.antecedent_name "aaa"
|
||||
f.consequent_name "bbb"
|
||||
end
|
||||
|
@ -1,8 +1,76 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TagImplicationsControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
test "the truth" do
|
||||
assert true
|
||||
context "The tag implicationes controller" do
|
||||
setup do
|
||||
@user = Factory.create(:admin_user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
MEMCACHE.flush_all
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
context "index action" do
|
||||
setup do
|
||||
@tag_implication = Factory.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb", :creator => @user)
|
||||
end
|
||||
|
||||
should "list all tag implications" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
should "list all tag_implications (with search)" do
|
||||
get :index, {:search => {:antecedent_name_matches => "aaa"}}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "edit action" do
|
||||
setup do
|
||||
@tag_implication = Factory.create(:tag_implication, :creator => @user)
|
||||
end
|
||||
|
||||
should "render" do
|
||||
get :edit, {:id => @tag_implication.id}, {:user_id => @user.id}
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
context "create action" do
|
||||
should "create a tag implication" do
|
||||
assert_difference("TagImplication.count", 1) do
|
||||
post :create, {:tag_implication => {:antecedent_name => "xxx", :consequent_name => "yyy"}}, {:user_id => @user.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "update action" do
|
||||
setup do
|
||||
@tag_implication = Factory.create(:tag_implication, :creator => @user)
|
||||
end
|
||||
|
||||
should "update a tag_implication" do
|
||||
post :update, {:id => @tag_implication.id, :tag_implication => {:antecedent_name => "zzz"}}, {:user_id => @user.id}
|
||||
@tag_implication.reload
|
||||
assert_equal("zzz", @tag_implication.antecedent_name)
|
||||
end
|
||||
end
|
||||
|
||||
context "destroy action" do
|
||||
setup do
|
||||
@tag_implication = Factory.create(:tag_implication, :creator => @user)
|
||||
end
|
||||
|
||||
should "destroy a tag_implication" do
|
||||
assert_difference("TagImplication.count", -1) do
|
||||
post :destroy, {:id => @tag_implication.id}, {:user_id => @user.id}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user