Skip to content

Commit

Permalink
Refactor(contracts_controller_spec.rb): Use cancan matchers. Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisma committed Jan 10, 2017
1 parent 82ee32e commit 174605c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions spec/controllers/contracts_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
require 'rails_helper'
require 'spec_helper'
require 'cancan/matchers'

RSpec.describe ContractsController, type: :controller do
before(:each) do
@user = FactoryGirl.create(:user)
login_with @user
@project = FactoryGirl.create(:project)
@contract = FactoryGirl.create(:contract, hiwi: @user, chair: @project.chair, start_date: Date.new(2015,1), end_date: Date.new(2016,1))
@user_ability = Ability.new(@user)
@contract = FactoryGirl.create(:contract, hiwi: @user)
end

describe 'GET #dismiss' do
it 'dismisses a month for a contract for the current user' do
expect(DismissedMissingTimesheet.dates_for(@user,@contract).size).to eq(0)
expect(@user_ability.can? :show, @contract).to be true
expect(DismissedMissingTimesheet.dates_for(@user, @contract).size).to eq(0)
expect(Ability.new @user).to be_able_to(:show, @contract)

get :dismiss, {id: @contract.id, month: @contract.start_date.at_beginning_of_month}

expect(flash[:success]).not_to be nil
expect(DismissedMissingTimesheet.dates_for(@user,@contract).size).to eq(1)
expect(flash[:error]).to be nil
expect(DismissedMissingTimesheet.dates_for(@user, @contract).size).to eq(1)
end
end
end

0 comments on commit 174605c

Please sign in to comment.