-
Notifications
You must be signed in to change notification settings - Fork 48
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 #1743 from jdalphon/testing
Increasing test coverage
- Loading branch information
Showing
6 changed files
with
101 additions
and
82 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 |
---|---|---|
@@ -1,9 +1,2 @@ | ||
module NewsHelper | ||
def news_edit_menu_helper(make_link = false) | ||
render 'shared/edit_menu', type: 'news', typeName: 'News', obj: @news, make_link: make_link, escape_link: '/news' | ||
end | ||
|
||
def news_edit_helper(field, can_edit = false, make_link = true, url = '#') | ||
render 'shared/edit_info', type: 'news', field: field, value: @news[field], row_id: @news.id, can_edit: can_edit, make_link: make_link, href: url | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,2 @@ | ||
module TutorialsHelper | ||
def tutorial_edit_menu_helper(make_link = false) | ||
render 'shared/edit_menu', type: 'tutorial', typeName: 'Tutorial', obj: @tutorial, | ||
make_link: make_link, escape_link: tutorials_url | ||
end | ||
|
||
def tutorial_edit_helper(field, can_edit = false, make_link = true, url = '#') | ||
render 'shared/edit_info', type: 'tutorial', field: field, value: @tutorial[field], | ||
row_id: @tutorial.id, can_edit: can_edit, make_link: make_link, href: url | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,6 @@ | ||
module VisualizationsHelper | ||
def visualization_edit_menu_helper(make_link = false) | ||
render 'shared/edit_menu', type: 'visualization', typeName: 'Visualization', obj: @visualization, | ||
make_link: make_link, escape_link: visualizations_url | ||
end | ||
|
||
def visualization_edit_helper(field, can_edit = false, make_link = true, url = '#') | ||
render 'shared/edit_info', type: 'visualization', field: field, value: @visualization[field], | ||
row_id: @visualization.id, can_edit: can_edit, make_link: make_link, href: url | ||
end | ||
|
||
def visualization_content_helper(can_edit = false) | ||
render 'shared/newcontent', type: 'visualization', field: 'content', | ||
content: @visualization.content, row_id: @visualization.id, | ||
has_content: !@visualization.content.blank?, can_edit: can_edit | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,13 @@ | |
class PostNewsTest < ActionDispatch::IntegrationTest | ||
include CapyHelper | ||
|
||
self.use_transactional_fixtures = false | ||
|
||
setup do | ||
@unpublished = news(:unpublished_news) | ||
@to_rename = news(:rename_this_news) | ||
@to_delete = news(:delete_this_news) | ||
@to_update = news(:update_this_news) | ||
Capybara.current_driver = :webkit | ||
Capybara.default_wait_time = 15 | ||
end | ||
|
@@ -14,38 +20,80 @@ class PostNewsTest < ActionDispatch::IntegrationTest | |
|
||
test 'add a news item' do | ||
login('[email protected]', '12345') | ||
assert find('.navbar').has_content?('Richard N.') | ||
|
||
click_on 'News' | ||
assert page.has_no_content?('The Quick Brown Fox') | ||
|
||
find('#news_title').set('The Quick Green Fox') | ||
assert page.has_no_content?('New news item #1'), 'News item should not exist' | ||
|
||
find('#news_title').set('New news item #1') | ||
click_on 'Add News Item' | ||
assert page.has_content?('News entry was successfully created.') | ||
assert page.has_content?('The Quick Green Fox') | ||
|
||
find('.menu_edit_link').click | ||
click_on('Edit Title') | ||
find('#news_title').set('The Quick Brown Fox') | ||
all('.btn-success').first.click | ||
|
||
sleep 1 | ||
logout | ||
visit '/' | ||
login('[email protected]', '12345') | ||
click_on 'News' | ||
assert page.has_no_content?('New news item #1'), 'News was not published, should not be shown.' | ||
|
||
find('#hide_news_checkbox').click | ||
end | ||
|
||
sleep 1 | ||
test 'publish news' do | ||
login('[email protected]', '12345') | ||
click_on 'News' | ||
assert page.has_no_content?('Unpublished News'), 'News was not published, should not be shown.' | ||
|
||
visit '/news' | ||
logout | ||
visit '/' | ||
login('[email protected]', '12345') | ||
visit news_path(@unpublished) | ||
assert page.has_content?('Unpublished News'), 'Not on the news page' | ||
|
||
assert page.has_content?('The Quick Brown Fox'), 'News Was Added' | ||
find('#hide_news_checkbox').click | ||
sleep 1 | ||
|
||
logout | ||
|
||
visit '/' | ||
login('[email protected]', '12345') | ||
click_on 'News' | ||
assert page.has_content?('Unpublished News'), 'News was published, should be shown.' | ||
end | ||
|
||
test 'rename news' do | ||
login('[email protected]', '12345') | ||
visit news_path(@to_rename) | ||
assert page.has_content?('To be renamed'), 'Not on the right page' | ||
|
||
find('.menu_edit_link').click | ||
find('.menu_rename').click | ||
find('#news_title').set 'Changed' | ||
find('.fa-floppy-o').click | ||
|
||
assert page.has_content?('News was successfully updated.'), 'Failed to update title' | ||
assert page.has_content?('Changed'), 'Title should be changed' | ||
end | ||
|
||
test 'delete news' do | ||
login('[email protected]', '12345') | ||
visit news_path(@to_delete) | ||
assert page.has_content?('To be deleted'), 'Not on the right page' | ||
|
||
find('.menu_edit_link').click | ||
find('.menu_delete').click | ||
page.driver.browser.accept_js_confirms | ||
|
||
assert page.has_no_content?('To be deleted'), 'News was not deleted' | ||
end | ||
|
||
test 'add summary to news' do | ||
login('[email protected]', '12345') | ||
visit news_path(@to_update) | ||
assert page.has_content?('To be updated'), 'Not on the right page' | ||
|
||
find('.menu_edit_link').click | ||
find('.summary_edit').click | ||
find('#news_summary').set 'Updated to have a summary' | ||
find('.fa-floppy-o').click | ||
|
||
assert page.has_no_content?('Add News Item') | ||
assert page.has_content?('The Quick Brown Fox') | ||
assert page.has_content?('News was successfully updated.'), 'Failed to update summary' | ||
assert page.has_content?('Updated to have a summary'), 'Title should be changed' | ||
end | ||
end |