Fixes #voodoorai2000 comments

Fixes some comments from #voodoorai2000 for the PR to consul
This commit is contained in:
Juan Salvador Pérez García
2018-07-27 16:30:03 +02:00
parent a41ce7a0bd
commit 50f73abb0c
33 changed files with 541 additions and 404 deletions

View File

@@ -1,49 +1,29 @@
require 'rails_helper'
describe Dashboard::ExecutedAction do
subject do
build :dashboard_executed_action,
proposal: proposal,
action: action,
executed_at: executed_at
end
let(:proposal) { create :proposal }
let(:action) do
create :dashboard_action, request_to_administrators: request_to_administrators, link: Faker::Internet.url
end
let(:request_to_administrators) { false }
let(:executed_at) { Time.current }
it { should be_valid }
context 'when proposal is nil' do
let(:proposal) { nil }
it { should_not be_valid }
create :dashboard_action, request_to_administrators: true, link: Faker::Internet.url
end
context 'when action is nil' do
let(:action) { nil }
it { should_not be_valid }
it 'is invalid when proposal is nil' do
action = build(:dashboard_executed_action, proposal: nil)
expect(action).not_to be_valid
end
context 'when executed_at is nil' do
let(:executed_at) { nil }
it { should_not be_valid }
it 'is invalid when action is nil' do
action = build(:dashboard_executed_action, action: nil)
expect(action).not_to be_valid
end
context 'when the action sends a request to the administrators' do
let(:request_to_administrators) { true }
it { should be_valid }
it 'is invalid when executed_at is nil' do
action = build(:dashboard_executed_action, executed_at: nil)
expect(action).not_to be_valid
end
context 'when it has been already executed' do
let!(:executed) { create(:dashboard_executed_action, proposal: proposal, action: action) }
it { should_not be_valid }
it 'when action has been already executed it is invalid' do
_executed = create(:dashboard_executed_action, proposal: proposal, action: action)
action = build(:dashboard_executed_action, proposal: proposal, action: action)
expect(action).not_to be_valid
end
end