Sha256: 24026ec1d05d933b6791878fa03ae3224576d5012f52b415f245bbcf0119355b

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

require File.join(File.dirname(__FILE__),'api_helper')

describe "RhosyncApiUpdateUser" do
  it_should_behave_like "ApiHelper"
  
  it "should update user successfully" do
    post "/api/update_user", :api_token => @api_token, 
      :attributes => {:new_password => '123'}
    last_response.should be_ok
    user = User.authenticate('admin','123')
    user.login.should == 'admin'
    user.admin.should == 1
  end
  
  it "should fail to update user with wrong attributes" do
    post "/api/update_user", :api_token => @api_token,
      :attributes => {:missingattrib => '123'}
    last_response.status.should == 500
    last_response.body.match('undefined method').should_not be_nil
  end
  
  it "should not update login attribute for user" do
    post "/api/update_user", :api_token => @api_token, 
      :attributes => {:new_password => '123', :login => 'admin1'}
    last_response.should be_ok
    user = User.authenticate('admin','123')
    user.login.should == 'admin'
    user.admin.should == 1
    User.is_exist?('admin1').should == false
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rhosync-2.0.0.beta9 spec/api/update_user_spec.rb
rhosync-2.0.0.beta8 spec/api/update_user_spec.rb
rhosync-2.0.0.beta7 spec/api/update_user_spec.rb
rhosync-2.0.0.beta6 spec/api/update_user_spec.rb
rhosync-2.0.0.beta4 spec/api/update_user_spec.rb
rhosync-2.0.0.beta3 spec/api/update_user_spec.rb
rhosync-2.0.0.beta2 spec/api/update_user_spec.rb
rhosync-2.0.0.beta1 spec/api/update_user_spec.rb