Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

ruby on rails 3 - RSpec and CanCan Controller Testing -


i'm using rspec , cancan in project. i'm testing permission logic in specs related ability class. controllers want make sure i'm doing authorization check. set controller macro, doesn't seem working correctly.

so have 2 questions. one, strategy sufficient testing permission logic of controllers (or should testing controller authorization logic more)?

two, see i'm doing wrong make not work?

#plan_orders_controller.rb def approve   plan_order = planorder.find(params[:id])   authorize! :update, plan_order   current_user.approve_plan_order(plan_order)   redirect_to plan_order_workout_plan_url(plan_order) end  #controller_macros.rb def it_should_check_permissions(*actions)   actions.each |action|     "#{action} action should authorize user action"       @plan_order = factory(:plan_order, :id=>1)       ability = object.new       ability.extend(cancan::ability)       controller.stub!(:current_ability).and_return(ability)                action, :id => 1       ability.should_receive(:can?)     end   end     end 

the output rspec following

 failure/error: ability.should_receive(:can?)  (#<object:0x00000006d4fa20>).can?(any args)      expected: 1 time      received: 0 times  # ./spec/controllers/controller_macros/controller_macros.rb:27:in `block (2 levels) in it_should_check_permissions' 

i'm not sure method should checking when call !authorize in controller (or automatically called via load_and_authorize_resource)

should_receive expectation of happens in future. reverse these 2 lines:

get action, :id => 1 ability.should_receive(:can?) 

so have this:

ability.should_receive(:can?) action, :id => 1 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -