diff --git a/spec/models/map_spec.rb b/spec/models/map_spec.rb index d1486192..27227188 100644 --- a/spec/models/map_spec.rb +++ b/spec/models/map_spec.rb @@ -5,34 +5,5 @@ RSpec.describe Map, type: :model do it { is_expected.to validate_presence_of :name } it { is_expected.to validate_presence_of :permission } it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) } - - context 'permissions' do - let(:owner) { create :user } - let(:other_user) { create :user } - let(:map) { create :map, user: owner, permission: :commons } - let(:private_map) { create :map, user: owner, permission: :private } - let(:public_map) { create :map, user: owner, permission: :public } - - it 'prevents deletion by non-owner' do - expect(map.authorize_to_delete(other_user)).to eq false - expect(map.authorize_to_delete(owner)).to eq map - end - - it 'prevents visibility if private' do - expect(map.authorize_to_show(other_user)).to eq map - expect(map.authorize_to_show(owner)).to eq map - expect(private_map.authorize_to_show(owner)).to eq private_map - expect(private_map.authorize_to_show(other_user)).to eq false - end - - it 'only allows editing if commons or owned' do - expect(map.authorize_to_edit(other_user)).to eq map - expect(map.authorize_to_edit(owner)).to eq map - expect(private_map.authorize_to_edit(other_user)).to eq false - expect(private_map.authorize_to_edit(owner)).to eq private_map - expect(public_map.authorize_to_edit(other_user)).to eq false - expect(public_map.authorize_to_edit(owner)).to eq public_map - end - end end diff --git a/spec/models/synapse_spec.rb b/spec/models/synapse_spec.rb index dcf85358..6ba5ff22 100644 --- a/spec/models/synapse_spec.rb +++ b/spec/models/synapse_spec.rb @@ -10,33 +10,4 @@ RSpec.describe Synapse, type: :model do it { is_expected.to validate_inclusion_of(:permission).in_array Perm::ISSIONS.map(&:to_s) } it { is_expected.to validate_inclusion_of(:category).in_array ['from-to', 'both'] } it { is_expected.to validate_length_of(:desc).is_at_least(0) } # TODO don't allow nil - - context 'permissions' do - let(:owner) { create :user } - let(:other_user) { create :user } - let(:synapse) { create :synapse, user: owner, permission: :commons } - let(:private_synapse) { create :synapse, user: owner, permission: :private } - let(:public_synapse) { create :synapse, user: owner, permission: :public } - - it 'prevents deletion by non-owner' do - expect(synapse.authorize_to_delete(other_user)).to eq false - expect(synapse.authorize_to_delete(owner)).to eq synapse - end - - it 'prevents visibility if private' do - expect(synapse.authorize_to_show(other_user)).to eq synapse - expect(synapse.authorize_to_show(owner)).to eq synapse - expect(private_synapse.authorize_to_show(owner)).to eq private_synapse - expect(private_synapse.authorize_to_show(other_user)).to eq false - end - - it 'only allows editing if commons or owned' do - expect(synapse.authorize_to_edit(other_user)).to eq synapse - expect(synapse.authorize_to_edit(owner)).to eq synapse - expect(private_synapse.authorize_to_edit(other_user)).to eq false - expect(private_synapse.authorize_to_edit(owner)).to eq private_synapse - expect(public_synapse.authorize_to_edit(other_user)).to eq false - expect(public_synapse.authorize_to_edit(owner)).to eq public_synapse - end - end end diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index b499daac..ef8f0b7a 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -49,33 +49,4 @@ RSpec.describe Topic, type: :model do end end end - - context 'permssions' do - let(:owner) { create :user } - let(:other_user) { create :user } - let(:topic) { create :topic, user: owner, permission: :commons } - let(:private_topic) { create :topic, user: owner, permission: :private } - let(:public_topic) { create :topic, user: owner, permission: :public } - - it 'prevents deletion by non-owner' do - expect(topic.authorize_to_delete(other_user)).to eq false - expect(topic.authorize_to_delete(owner)).to eq topic - end - - it 'prevents visibility if private' do - expect(topic.authorize_to_show(other_user)).to eq topic - expect(topic.authorize_to_show(owner)).to eq topic - expect(private_topic.authorize_to_show(owner)).to eq private_topic - expect(private_topic.authorize_to_show(other_user)).to eq false - end - - it 'only allows editing if commons or owned' do - expect(topic.authorize_to_edit(other_user)).to eq topic - expect(topic.authorize_to_edit(owner)).to eq topic - expect(private_topic.authorize_to_edit(other_user)).to eq false - expect(private_topic.authorize_to_edit(owner)).to eq private_topic - expect(public_topic.authorize_to_edit(other_user)).to eq false - expect(public_topic.authorize_to_edit(owner)).to eq public_topic - end - end end