spec/models/permissions_spec.rb in volt-0.9.1 vs spec/models/permissions_spec.rb in volt-0.9.2

- old
+ new

@@ -1,8 +1,7 @@ require 'spec_helper' - class TestUserTodo < Volt::Model own_by_user permissions(:update) do deny :user_id @@ -45,11 +44,11 @@ self.read_check = true allow end end -describe "model permissions" do +describe 'model permissions' do it 'should follow CRUD states when checking permissions' do todo = TestUserTodoWithCrudStates.new.buffer spec_err = nil @@ -57,30 +56,27 @@ todo.save!.then do # Don't allow it to change todo._name = 'Jimmy' todo.save!.then do - spec_err = "should not have saved" + spec_err = 'should not have saved' end.fail do |err| - expect(err).to eq({:name=>["can not be changed"]}) + expect(err).to eq(name: ['can not be changed']) end end.fail do |err| spec_err = "Did not save because: #{err.inspect}" end - if spec_err - fail spec_err - end + fail spec_err if spec_err end # it 'should deny an insert/create if a deny without fields' do # store._todos << {name: 'Ryan'} # end - if RUBY_PLATFORM != 'opal' - describe "read permissions" do + describe 'read permissions' do it 'should deny read on a field' do model = store._test_deny_read_names!.buffer model._name = 'Jimmy' model._other = 'should be visible' @@ -111,11 +107,11 @@ expect(count).to eq(1) end end it 'should not check the read permissions when updating (so that all fields are present for the permissions check)' do - model = store._test_update_read_checks!.append({name: 'Ryan'}).sync + model = store._test_update_read_checks!.append(name: 'Ryan').sync expect(model.create_check).to eq(true) expect(model.read_check).to eq(nil) # Update @@ -144,15 +140,15 @@ expect(model.save_to.read_check).to eq(nil) expect(model.save_to.update_check).to eq(true) end it 'should not check read on delete, so all fields are available to the permissions block' do - model = store._test_update_read_checks!.append({name: 'Ryan'}).sync + model = store._test_update_read_checks!.append(name: 'Ryan').sync expect(model.read_check).to eq(nil) model.destroy expect(model.read_check).to eq(nil) end end -end \ No newline at end of file +end