-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #487 from cedarcode/sr--add-suppor-for-activity-pr…
…erequisites Añadir soporte para previas 'Actividad de instancia aprobada/reprobada'
- Loading branch information
Showing
10 changed files
with
161 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ActivityPrerequisite < Prerequisite | ||
belongs_to :approvable_needed, class_name: "Approvable" | ||
|
||
def met?(approved_approvable_ids) | ||
approvable_needed.available?(approved_approvable_ids) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
app/views/activity_prerequisites/_activity_prerequisite.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<%= link_to subject_path(activity_prerequisite.approvable_needed.subject), class: 'mdc-deprecated-list-item' do %> | ||
<span class="mdc-deprecated-list-item__ripple"></span> | ||
<span class="mdc-deprecated-list-item__text"> | ||
<%= negative ? "No haber" : "Haber" %> | ||
<%= display_activity_prerequisite(activity_prerequisite) %> | ||
</span> | ||
|
||
<%= render 'prerequisites/met_checkmark', prerequisite: activity_prerequisite, negative: %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe ActivityPrerequisite, type: :model do | ||
describe '#met?' do | ||
context 'when the approvable needed is available' do | ||
it 'returns true' do | ||
subject_needed = create :subject, :with_exam | ||
allow(subject_needed.exam).to receive(:available?).and_return(true) | ||
prerequisite = create :activity_prerequisite, approvable_needed: subject_needed.exam | ||
|
||
expect(prerequisite.met?([])).to be_truthy | ||
end | ||
end | ||
|
||
context 'when the approvable needed is not available' do | ||
it 'returns false' do | ||
subject_needed = create :subject, :with_exam | ||
allow(subject_needed.exam).to receive(:available?).and_return(false) | ||
prerequisite = create :activity_prerequisite, approvable_needed: subject_needed.exam | ||
|
||
expect(prerequisite.met?([])).to be_falsey | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters