-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
653279f
commit 3901dd5
Showing
5 changed files
with
112 additions
and
1 deletion.
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,14 @@ | ||
require "test_helper" | ||
|
||
class GroupTest < ActiveSupport::TestCase | ||
def setup | ||
@subject = build(:group) | ||
end | ||
|
||
test "should be valid" do | ||
assert @subject.valid? | ||
end | ||
|
||
test("name required") { assert_present(:name) } | ||
test("age_in_months required") { assert_present(:age_in_months) } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
require "application_system_test_case" | ||
|
||
class ContentsTest < ApplicationSystemTestCase | ||
setup do | ||
@admin = create(:admin) | ||
end | ||
|
||
test "creating new group" do | ||
sign_in | ||
visit groups_path | ||
|
||
click_on "Create content group" | ||
|
||
fill_in "Name", with: "Default content" | ||
fill_in "Age in months", with: "17" | ||
click_on "Create" | ||
|
||
assert_text "Content group successfully created" | ||
assert_text "Default content" | ||
end | ||
|
||
test "shows errors" do | ||
sign_in | ||
visit groups_path | ||
|
||
click_on "Create content group" | ||
|
||
click_on "Create" | ||
|
||
assert_field_has_errors("Name") | ||
assert_field_has_errors("Age in months") | ||
end | ||
|
||
test "updating a group" do | ||
create(:group, name: "Old group name") | ||
|
||
sign_in | ||
visit groups_path | ||
|
||
assert_text "Old group name" | ||
|
||
click_on "Edit", match: :first | ||
|
||
fill_in "Name", with: "New group name" | ||
click_on "Update" | ||
|
||
assert_text "Content group updated" | ||
assert_text "New group name" | ||
end | ||
|
||
private | ||
|
||
def sign_in | ||
visit new_admin_session_path | ||
fill_in "Email", with: @admin.email | ||
fill_in "Password", with: @admin.password | ||
click_on "Log in" | ||
assert_text "Signed in successfully." | ||
end | ||
end |