Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Expanding from the comments.</p> <p>Based on <a href="https://github.com/ryanb/cancan/wiki/Testing-Abilities" rel="nofollow">https://github.com/ryanb/cancan/wiki/Testing-Abilities</a> I do the following to test.</p> <p>Inside my Administrator spec .</p> <pre><code>require 'spec_helper' require 'cancan/matchers' describe Administrator do describe "abilities" do subject { ability } let(:ability) { Ability.new(admin) } let(:account) { FactoryGirl.create :account, isp: admin.isp } context "is a helpdesk admin" do let(:admin) { FactoryGirl.create :helpdesk_admin } let(:mail_user) {FactoryGirl.create :mail_user, account: account} let(:web_user) {FactoryGirl.create :web_user, account: account } let(:radius_user) { FactoryGirl.create :radius_user, account: account} it { should be_able_to(:change_password,mail_user)} it { should be_able_to(:change_password,radius_user)} it { should be_able_to(:change_password,web_user)} it { should_not be_able_to(:manage, Account.new) } end context "is a realm admin" do let(:admin) { FactoryGirl.create :realm_admin } it{ should be_able_to(:manage, MailDomain.new)} it{ should be_able_to(:manage, RadiusDomain.new)} it{ should be_able_to(:manage, WebDomain.new)} it{ should be_able_to(:manage, Administrator.new)} end end </code></pre> <p>This lets me test the abilities that Each Role has assigned </p> <p>Then inside my features/ I do something like this for each controller, to make sure that I don't forget an authorize.</p> <pre><code>context "regular admin" do let(:admin) {FactoryGirl.create(:admin)} before(:each) do visit login_path fill_in "email" , with: admin.email fill_in "password", with: admin.password click_button "Sign in" end it "shoudln't allow them to add new admins" do visit new_administrator_path page.should have_content "You are not authorized to access this page." end end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload