Skip to content

Commit

Permalink
MDL-49412 badges: Fix behat failures
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitagarwal authored and abgreeve committed Apr 10, 2015
1 parent 06d631f commit ae0bf67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
5 changes: 2 additions & 3 deletions badges/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@
function core_badges_myprofile_navigation(\core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
global $CFG, $PAGE, $USER, $SITE;
require_once($CFG->dirroot . '/badges/renderer.php');
if (empty($CFG->enablebadges) || (!empty($course) || empty($CFG->badges_allowcoursebadges))) {
if (empty($CFG->enablebadges) || (!empty($course) && empty($CFG->badges_allowcoursebadges))) {
// Y U NO LIKE BADGES ?
return true;
}
$category = new core_user\output\myprofile\category('badges', get_string('badges', 'badges'), null);
$url = new moodle_url("/badges/mybadges.php");

// Add category.
$category = new core_user\output\myprofile\category('badges', get_string('badges', 'badges'), null);
$tree->add_category($category);

// Determine context.
Expand Down
30 changes: 16 additions & 14 deletions badges/tests/behat/award_badge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ Feature: Award badges
And I should not see "Criteria for this badge have not been set up yet."
And I press "Enable access"
And I press "Continue"
And I expand "My profile settings" node
And I click on "Admin User" "link"
And I follow "My profile" in the open menu
And I follow "Edit profile"
And I expand all fieldsets
And I set the field "Phone" to "123456789"
And I press "Update profile"
And I navigate to "My badges" node in "My profile"
And I follow "My profile" in the user menu
Then I should see "Profile Badge"
And I should not see "There are no badges available."

Expand Down Expand Up @@ -68,7 +69,7 @@ Feature: Award badges
Then I should see "Recipients (2)"
And I log out
And I log in as "student"
And I navigate to "My badges" node in "My profile"
And I follow "My profile" in the user menu
Then I should see "Site Badge"

@javascript
Expand Down Expand Up @@ -111,9 +112,9 @@ Feature: Award badges
Then I should see "Recipients (2)"
And I log out
And I log in as "student1"
And I follow "My profile" in the user menu
And I follow "Course 1"
And I navigate to "My badges" node in "My profile"
Then I should see "Course Badge"
And I should see "Course Badge"

@javascript
Scenario: Award badge on activity completion
Expand Down Expand Up @@ -156,13 +157,14 @@ Feature: Award badges
When I press "Continue"
And I log out
And I log in as "student1"
And I follow "My profile" in the user menu
And I follow "Course 1"
And I navigate to "My badges" node in "My profile"
Then I should see "There are no badges available."
And I follow "Home"
Then I should not see "badges"
And I am on homepage
And I follow "Course 1"
And I press "Mark as complete: Test assignment name"
And I navigate to "My badges" node in "My profile"
And I follow "My profile" in the user menu
And I follow "Course 1"
Then I should see "Course Badge"

@javascript
Expand Down Expand Up @@ -212,10 +214,10 @@ Feature: Award badges
When I press "Continue"
And I log out
And I log in as "student1"
And I follow "My profile" in the user menu
And I follow "Course 1"
And I navigate to "My badges" node in "My profile"
Then I should see "There are no badges available."
And I follow "Home"
Then I should not see "badges"
And I am on homepage
And I follow "Course 1"
And I press "Mark as complete: Test assignment name"
And I log out
Expand All @@ -227,8 +229,8 @@ Feature: Award badges
And I wait "61" seconds
And I trigger cron
# Finally the admin goes back to homepage to continue the user story.
And I am on homepage
And I am on site homepage
And I log out
And I log in as "student1"
And I navigate to "My badges" node in "My profile"
And I follow "My profile" in the user menu
Then I should see "Course Badge"

0 comments on commit ae0bf67

Please sign in to comment.