spec/api/rhosync_api_spec.rb in rhosync-2.0.9 vs spec/api/rhosync_api_spec.rb in rhosync-2.1.0.beta.1

- old
+ new

@@ -45,10 +45,21 @@ RestClient.stub(:post).and_return("User created") RestClient.should_receive(:post).once RhosyncApi::create_user('some_url',@api_token,'testuser1','testpass1').should == "User created" end + it "should update user using direct api call" do + RhosyncApi::update_user('',@api_token, {:new_password => '123'}) + User.authenticate('rhoadmin','123').login.should == 'rhoadmin' + end + + it "should update user using rest call" do + RestClient.stub(:post) + RestClient.should_receive(:post).once + RhosyncApi::update_user('some_url',@api_token, {:new_password => '123'}) + end + it "should delete user direct api call" do RhosyncApi::create_user('',@api_token,'testuser1','testpass1').should == "User created" User.is_exist?('testuser1').should == true RhosyncApi::delete_user('',@api_token,'testuser1').should == "User deleted" User.is_exist?('testuser1').should == false @@ -299,8 +310,23 @@ res = mock('HttpResponse') res.stub!(:body).and_return(['data'].to_json) RestClient.stub(:post).and_return(res) RestClient.should_receive(:post).once RhosyncApi::get_license_info('some_url',@api_token) + end + + it "should get stats using direct api call" do + Rhosync.stats = true + Store.set_value('stat:foo','bar') + RhosyncApi::stats('',@api_token,:metric => 'foo').should == 'bar' + Rhosync.stats = false + end + + it "should get stats using rest call" do + res = mock('HttpResponse') + res.stub!(:body).and_return('bar') + RestClient.stub(:post).and_return(res) + RestClient.should_receive(:post).once.and_return(res) + RhosyncApi::stats('some_url',@api_token,:metric => 'foo') end end \ No newline at end of file