scinote-web/spec/controllers/client_api/permissions_controller_spec.rb

24 lines
688 B
Ruby
Raw Normal View History

2017-12-04 20:25:48 +08:00
require 'rails_helper'
describe ClientApi::PermissionsController, type: :controller do
login_user
2017-12-13 15:57:50 +08:00
describe '#status' do
2018-01-08 23:28:20 +08:00
let!(:user) { User.first || create(:user) }
let!(:team) { create :team, created_by: user }
let!(:user_team) { create :user_team, user: user, team: team, role: 2 }
2017-12-04 20:25:48 +08:00
let(:params) do
2018-01-08 23:28:20 +08:00
{ requiredPermissions: ['can_read_team'],
resource: { type: 'Team', id: team.id } }
2017-12-04 20:25:48 +08:00
end
2018-01-08 23:28:20 +08:00
2017-12-13 15:57:50 +08:00
let(:subject) { post :status, format: :json, params: params }
2017-12-04 20:25:48 +08:00
it { is_expected.to be_success }
2018-01-08 23:28:20 +08:00
it 'returns an object with the permission' do
body = JSON.parse(subject.body)
expect(body).to eq('can_read_team' => true)
end
2017-12-04 20:25:48 +08:00
end
end