Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def create_user(user_options = {}, other_options = {})
- base_options = { :login => 'unique', :email => 'unique@example.com',
- :first_name => 'bob', :last_name => 'testerperson', :address => "123 Main St",
- :city => "Santa Carla", :state => "CA", :zip => "95000", :subscription => "Tier 1",
- :role => 'Member',
- :password => 'quire69', :password_confirmation => 'quire69',:accept_terms => true }
- post :create, {:user => (base_options.merge(user_options))}.merge(other_options)
- end
- it 'should set permissions on create' do
- pretend_to_be_authenticated("Administrator")
- quentin = users( :quentin)
- quentin.stub!( :match_permissions_with_subscription!)
- rebecca = content_categories(:rebecca)
- todd = content_categories(:todd)
- howard = content_categories(:howard)
- brian = content_categories(:brian)
- ContentCategory.should_receive(:find_by_name).with("REBECCA RUNKLE").and_return(rebecca)
- ContentCategory.should_receive(:find_by_name).with("TODD JORDAN").and_return(todd)
- ContentCategory.should_receive(:find_by_name).with("HOWARD PENNEY").and_return(howard)
- ContentCategory.should_receive(:find_by_name).with("BRIAN McGOUGH").and_return(brian)
- quentin.should_receive(:set_permission).with(rebecca, Permission::TIER_1, nil, nil)
- quentin.should_receive(:set_permission).with(todd, Permission::TIER_2, nil, nil)
- quentin.should_receive(:set_permission).with(howard, Permission::TRIAL_FULL_TEXT, "1/1/2011", "1/7/2011")
- quentin.should_receive(:set_permission).with(brian, Permission::TRIAL_REWIND, "1/8/2011", "1/15/2011")
- quentin.should_receive(:permissions_valid?).and_return(true)
- quentin.stub!(:valid?).and_return(true)
- quentin.stub!(:credit_card_subscriber?).and_return(false)
- quentin.should_receive(:activate)
- quentin.should_receive(:save!)
- User.stub!(:find_by_email).and_return(quentin)
- create_user({:subscription => "Tier 1" },
- {
- :permissions => {
- "REBECCA RUNKLE" => {:permission_type => Permission::TIER_1},
- "TODD JORDAN" => {:permission_type => Permission::TIER_2},
- "HOWARD PENNEY" => {:permission_type => Permission::TRIAL_FULL_TEXT, :trial_start => "1/1/2011", :trial_end => "1/7/2011"},
- "BRIAN McGOUGH" => {:permission_type => Permission::TRIAL_REWIND, :trial_start => "1/8/2011", :trial_end => "1/15/2011"}
- }
- })
- end
- it 'should remove specified permissions on create' do
- pretend_to_be_authenticated("Administrator")
- quentin = users( :quentin)
- quentin.stub!( :match_permissions_with_subscription!)
- rebecca = content_categories(:rebecca)
- todd = content_categories(:todd)
- howard = content_categories(:howard)
- brian = content_categories(:brian)
- ContentCategory.should_receive(:find_by_name).with("REBECCA RUNKLE").and_return(rebecca)
- ContentCategory.should_receive(:find_by_name).with("TODD JORDAN").and_return(todd)
- ContentCategory.should_receive(:find_by_name).with("HOWARD PENNEY").and_return(howard)
- ContentCategory.should_receive(:find_by_name).with("BRIAN McGOUGH").and_return(brian)
- quentin.should_receive(:set_permission).with(rebecca, Permission::NONE, nil, nil)
- quentin.should_receive(:set_permission).with(todd, Permission::NONE, nil, nil)
- quentin.should_receive(:set_permission).with(howard, Permission::TRIAL_FULL_TEXT, "1/1/2011", "1/7/2011")
- quentin.should_receive(:set_permission).with(brian, Permission::TRIAL_REWIND, "1/8/2011", "1/15/2011")
- quentin.should_receive(:permissions_valid?).and_return(true)
- quentin.stub!(:valid?).and_return(true)
- quentin.stub!(:credit_card_subscriber?).and_return(false)
- quentin.should_receive(:activate)
- quentin.should_receive(:save!)
- User.stub!(:find_by_email).and_return(quentin)
- create_user({:subscription => "Tier 1" },
- {
- :permissions => {
- "REBECCA RUNKLE" => {:permission_type => Permission::NONE},
- "TODD JORDAN" => {:permission_type => Permission::NONE},
- "HOWARD PENNEY" => {:permission_type => Permission::TRIAL_FULL_TEXT, :trial_start => "1/1/2011", :trial_end => "1/7/2011"},
- "BRIAN McGOUGH" => {:permission_type => Permission::TRIAL_REWIND, :trial_start => "1/8/2011", :trial_end => "1/15/2011"}
- }
- })
- end
Add Comment
Please, Sign In to add comment