add tag impl functional test
This commit is contained in:
@@ -1,19 +1,37 @@
|
|||||||
class TagImplicationsController < ApplicationController
|
class TagImplicationsController < ApplicationController
|
||||||
|
before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy]
|
||||||
|
respond_to :html, :xml, :json
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@tag_implication = TagImplication.new
|
||||||
|
respond_with(@tag_implication)
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@tag_implication = TagImplication.find(params[:id])
|
||||||
|
respond_with(@tag_implication)
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@search = TagImplication.search(params[:search])
|
||||||
|
@tag_implicationes = @search.paginate(:page => params[:page])
|
||||||
|
respond_with(@tag_implicationes)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@tag_implication = TagImplication.create(params[:tag_implication])
|
||||||
|
respond_with(@tag_implication)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
@tag_implication = TagImplication.find(params[:id])
|
||||||
|
@tag_implication.update_attributes(params[:tag_implication])
|
||||||
|
respond_with(@tag_implication)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
@tag_implication = TagImplication.find(params[:id])
|
||||||
|
@tag_implication.destroy
|
||||||
|
respond_with(@tag_implication)
|
||||||
end
|
end
|
||||||
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|
|
Factory.define(:tag_implication) do |f|
|
||||||
|
f.antecedent_name "aaa"
|
||||||
|
f.consequent_name "bbb"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,8 +1,76 @@
|
|||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TagImplicationsControllerTest < ActionController::TestCase
|
class TagImplicationsControllerTest < ActionController::TestCase
|
||||||
# Replace this with your real tests.
|
context "The tag implicationes controller" do
|
||||||
test "the truth" do
|
setup do
|
||||||
assert true
|
@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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user