allow editing of pending aliases/implications

This commit is contained in:
r888888888
2014-07-18 14:48:51 -07:00
parent 5fd6a018cb
commit c1a4bfda55
11 changed files with 173 additions and 3 deletions

View File

@@ -15,17 +15,58 @@ class TagAliasesControllerTest < ActionController::TestCase
CurrentUser.ip_addr = nil
end
context "edit action" do
setup do
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
end
should "render" do
get :edit, {:id => @tag_alias.id}
assert_response :success
end
end
context "update action" do
setup do
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
end
context "for a pending alias" do
setup do
@tag_alias.update_attribute(:status, "pending")
end
should "succeed" do
post :update, {:id => @tag_alias.id, :tag_alias => {:antecedent_name => "xxx"}}, {:user_id => @user.id}
@tag_alias.reload
assert_equal("xxx", @tag_alias.antecedent_name)
end
end
context "for an approved alias" do
setup do
@tag_alias.update_attribute(:status, "approved")
end
should "fail" do
post :update, {:id => @tag_alias.id, :tag_alias => {:antecedent_name => "xxx"}}, {:user_id => @user.id}
@tag_alias.reload
assert_equal("aaa", @tag_alias.antecedent_name)
end
end
end
context "index action" do
setup do
@tag_alias = FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
end
should "list all tag aliass" do
should "list all tag alias" do
get :index, {}, {:user_id => @user.id}
assert_response :success
end
should "list all tag_aliass (with search)" do
should "list all tag_alias (with search)" do
get :index, {:search => {:antecedent_name => "aaa"}}, {:user_id => @user.id}
assert_response :success
end

View File

@@ -15,6 +15,48 @@ class TagImplicationsControllerTest < ActionController::TestCase
CurrentUser.ip_addr = nil
end
context "edit action" do
setup do
@tag_implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
end
should "render" do
get :edit, {:id => @tag_implication.id}
assert_response :success
end
end
context "update action" do
setup do
@tag_implication = FactoryGirl.create(:tag_implication, :antecedent_name => "aaa", :consequent_name => "bbb")
end
context "for a pending implication" do
setup do
@tag_implication.update_attribute(:status, "pending")
end
should "succeed" do
post :update, {:id => @tag_implication.id, :tag_implication => {:antecedent_name => "xxx"}}, {:user_id => @user.id}
@tag_implication.reload
assert_equal("xxx", @tag_implication.antecedent_name)
end
end
context "for an approved implication" do
setup do
@tag_implication.update_attribute(:status, "approved")
end
should "fail" do
post :update, {:id => @tag_implication.id, :tag_implication => {:antecedent_name => "xxx"}}, {:user_id => @user.id}
@tag_implication.reload
assert_equal("aaa", @tag_implication.antecedent_name)
end
end
end
context "index action" do
setup do
CurrentUser.scoped(@user, "127.0.0.1") do