jam-cloud/web/spec/controllers/api_schools_controller_spec.rb

34 lines
793 B
Ruby

require 'spec_helper'
describe ApiSchoolsController, type: :controller do
render_views
let (:owner) {FactoryGirl.create(:user)}
let (:school) {FactoryGirl.create(:school, user: owner)}
before(:each) do
controller.current_user = owner
end
describe "show" do
it "works" do
get :show, params: { id: school.id }
response.should be_success
JSON.parse(response.body)['id'].should eql school.id
end
end
describe "update" do
it "works" do
post :update, params: { id: school.id, name: "Hardy har", scheduling_communication: 'school' }, as: 'json'
response.should be_success
json = JSON.parse(response.body)
json['name'].should eql "Hardy har"
json['scheduling_communication'].should eql 'school'
end
end
end