require 'spec_helper' # user progression is achieved by different aspects of the code working together in a cross-cutting fashion. # due to this, it's nice to have a single place where all the parts of user progression are tested # https://jamkazam.atlassian.net/wiki/pages/viewpage.action?pageId=3375145 describe "Diagnostics", :type => :api do let(:user) { FactoryGirl.create(:user) } subject { page } def login(user) post '/sessions', "session[email]" => user.email, "session[password]" => user.password rack_mock_session.cookie_jar["remember_token"].should == user.remember_token end describe "create" do before do Diagnostic.delete_all login(user) end it "can fail" do post "/api/diagnostics.json", {}.to_json, "CONTENT_TYPE" => 'application/json' last_response.status.should eql(422) JSON.parse(last_response.body).should eql({"errors"=>{"type"=>["is not included in the list"]}}) Diagnostic.count.should == 0 end it "can succeed" do post "/api/diagnostics.json", { type: Diagnostic::NO_HEARTBEAT_ACK}.to_json, "CONTENT_TYPE" => 'application/json' last_response.status.should eql(201) Diagnostic.count.should == 1 end end end