Skip to content

Commit

Permalink
Merge remote-tracking branch 'AgileVentures/develop' into sprint68-ca…
Browse files Browse the repository at this point in the history
…p-deploy-1time-tasks-#166136006
  • Loading branch information
weedySeaDragon committed May 31, 2019
2 parents 1655127 + 2ac47fb commit 75f4fa4
Show file tree
Hide file tree
Showing 37 changed files with 592 additions and 197 deletions.
18 changes: 18 additions & 0 deletions app/models/admin_only/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ class AppConfiguration < ApplicationRecord
scope :config_to_use, -> { last }


# Helpful method to get all images for the configuration
def self.image_attributes
[:chair_signature,
:sweden_dog_trainers,
:h_brand_logo,
:shf_logo
].freeze
end


def image_attributes
self.class.image_attributes
end


# =========================================================================


private

def url_for_images
Expand Down
66 changes: 33 additions & 33 deletions features/admin-dashboard/admin_search_everything_tool.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,36 @@ Feature: Admin can search on everything and save results
I would really like to be able to save searches so I can run them again.


Background:

Given the following users exists
| email | admin | member |
| emma_member@mutts.se | | true |
| hans_member@mutts.se | | true |
| anna@nosnarkybarky.se | | |
| lars_under_review@mutts.com | | |
| admin@shf.com | true | |

Given the following business categories exist
| name | description |
| dog grooming | grooming dogs from head to tail |
| rehab | physical rehabilitation |

Given the following regions exist:
| name |
| Stockholm |

Given the following companies exist:
| name | company_number | email | region |
| Bow Wow Wow | 5560360793 | hellow@bowwowwow.se | Stockholm |
| Mutts R Us | 5562252998 | voof@mutts.se | Stockholm |

And the following applications exist:
| user_email | company_number | categories | state |
| emma_member@mutts.se | 5562252998 | rehab | accepted |
| hans_member@mutts.se | 5562252998 | dog grooming | accepted |
| lars_under_review@mutts.se | 5562252998 | dog grooming | under_review |
| anna@nosnarkybarky.se | 5560360793 | rehab | under_review |

And I am logged in as "admin@shf.se"

# Background:
#
# Given the following users exists
# | email | admin | member |
# | emma_member@mutts.se | | true |
# | hans_member@mutts.se | | true |
# | anna@nosnarkybarky.se | | |
# | lars_under_review@mutts.com | | |
# | admin@shf.com | true | |
#
# Given the following business categories exist
# | name | description |
# | dog grooming | grooming dogs from head to tail |
# | rehab | physical rehabilitation |
#
# Given the following regions exist:
# | name |
# | Stockholm |
#
# Given the following companies exist:
# | name | company_number | email | region |
# | Bow Wow Wow | 5560360793 | hellow@bowwowwow.se | Stockholm |
# | Mutts R Us | 5562252998 | voof@mutts.se | Stockholm |
#
# And the following applications exist:
# | user_email | company_number | categories | state |
# | emma_member@mutts.se | 5562252998 | rehab | accepted |
# | hans_member@mutts.se | 5562252998 | dog grooming | accepted |
# | lars_under_review@mutts.se | 5562252998 | dog grooming | under_review |
# | anna@nosnarkybarky.se | 5560360793 | rehab | under_review |
#
# And I am logged in as "admin@shf.se"
#
33 changes: 17 additions & 16 deletions features/admin_only/admin_edits_app_config.feature
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
Feature: Admin edits application configuration
As an admin
I want to be able to edit application configuration
Including chair signature and SHG logo images
And images for company h-brand
including images for the site meta image, chair signature, SHF logo images, and company h-brand;
site name, and meta information: title, keywords, and description.


Background:
Given the following users exists
| email | password | admin | member | first_name | last_name |
| admin@random.com | password | true | false | emma | admin |

Scenario: Admin uploads SHF logo and chairperson signature
Given I am logged in as "admin@random.com"
And the App Configuration is not mocked and is seeded

And I am logged in as "admin@random.com"
And I am on the "admin edit app configuration" page
And I should see t("admin_only.app_configuration.edit.title")
And I choose an SHF "admin_only_app_configuration[chair_signature]" file named "chair_signature.png" to upload
And I choose an SHF "admin_only_app_configuration[shf_logo]" file named "shf_logo.png" to upload


Scenario: Admin uploads SHF logo and chairperson signature
Then I should see t("admin_only.app_configuration.edit.title")
And I choose an application configuration "admin_only_app_configuration[chair_signature]" file named "chair_signature.png" to upload
And I choose an application configuration "admin_only_app_configuration[shf_logo]" file named "shf_logo.png" to upload
And I click on t("submit") button
Then I should see t("admin_only.app_configuration.update.success")

Scenario: Admin uploads images for company h-brand
Given I am logged in as "admin@random.com"
And I am on the "admin edit app configuration" page
And I should see t("admin_only.app_configuration.edit.title")
And I choose an SHF "admin_only_app_configuration[h_brand_logo]" file named "h_brand_logo.png" to upload
And I choose an SHF "admin_only_app_configuration[sweden_dog_trainers]" file named "sweden_dog_trainers.png" to upload
Then I should see t("admin_only.app_configuration.edit.title")
And I choose an application configuration "admin_only_app_configuration[h_brand_logo]" file named "h_brand_logo.png" to upload
And I choose an application configuration "admin_only_app_configuration[sweden_dog_trainers]" file named "sweden_dog_trainers.png" to upload
And I click on t("submit") button
Then I should see t("admin_only.app_configuration.update.success")

Scenario: Admin edits app configuration and tries to upload non-image file
Given I am logged in as "admin@random.com"
And I am on the "admin edit app configuration" page
And I should see t("admin_only.app_configuration.edit.title")
And I choose an SHF "admin_only_app_configuration[shf_logo]" file named "text_file.jpg" to upload
Then I should see t("admin_only.app_configuration.edit.title")
And I choose an application configuration "admin_only_app_configuration[shf_logo]" file named "specifications.txt" to upload
And I click on t("submit") button
Then I should see t("admin_only.app_configuration.update.error")
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Feature: Admin enables/disables the emails sent when a new application is receiv
| name | company_number | email | region |
| No More Snarky Barky | 5560360793 | snarky@snarkybarky.com | Stockholm |

And the App Configuration is not mocked and is seeded


@selenium
Scenario: Admin disables send new app received emails
Expand Down
1 change: 1 addition & 0 deletions features/admins/show-user-account-to-admin.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Feature: Admin sees user account information
PT: https://www.pivotaltracker.com/story/show/140358959

Background:
Given the App Configuration is not mocked and is seeded

Given the following users exists
| email | admin | membership_number | member |
Expand Down
6 changes: 4 additions & 2 deletions features/admins/users_list_edit_member_packets_sent.feature
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ Feature: Admin sets when member packets were sent on the all users page

@selenium
Scenario: I set the membership packet sent to today for a user
Given I am on the "all users" page
Given the App Configuration is not mocked and is seeded
And I am on the "all users" page
And the date is set to "2019-03-01"
Then I should see the checkbox with id "date_membership_packet_sent" unchecked in the row for user "hannah@happymutts.se"
When I check the checkbox with id "date_membership_packet_sent" for the row with "hannah@happymutts.se"
Expand All @@ -69,7 +70,8 @@ Feature: Admin sets when member packets were sent on the all users page

@selenium
Scenario: I clear the membership packet sent date for a user
Given I am on the "all users" page
Given the App Configuration is not mocked and is seeded
And I am on the "all users" page
Then I should see the checkbox with id "date_membership_packet_sent" checked in the row for user "lars@happymutts.se"
When I uncheck the checkbox with id "date_membership_packet_sent" for the row with "lars@happymutts.se"
Then I should see the checkbox with id "date_membership_packet_sent" unchecked in the row for user "lars@happymutts.se"
Expand Down
2 changes: 2 additions & 0 deletions features/approve-member.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Feature: As an admin
PT: https://www.pivotaltracker.com/story/show/135472437

Background:
Given the App Configuration is not mocked and is seeded

Given the following users exists
| email | admin |
| emma@happymutts.se | |
Expand Down
1 change: 1 addition & 0 deletions features/emails/email-applicant-membership-granted.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Feature: Applicant gets an email when membership has been granted. (They are now
@time_adjust
Scenario: Applicant pays all fees, membership is granted; applicant gets email
Given the date is set to "2018-01-01"
And the App Configuration is not mocked and is seeded
When I am in "emma@happymutts.se" browser
And I am logged in as "emma@happymutts.se"
And I am on the "user details" page for "emma@happymutts.se"
Expand Down
2 changes: 2 additions & 0 deletions features/membership_status/member-status-change.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Feature: Membership status updated due to payments or expiration

Background:

Given the App Configuration is not mocked and is seeded

Given the following users exist
| email | admin | member | membership_number |
| emma@mutts.com | | true | 1001 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Feature: As an admin
So that I have flexibility in managing membership status

Background:
Given the App Configuration is not mocked and is seeded

Given the following users exist
| email | admin | member | membership_number |
| emma@mutts.com | | true | 1001 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Feature: As a member
I need to be able to pay my membership fee

Background:
Given the App Configuration is not mocked and is seeded

Given the date is set to "2017-01-10"
Given the following users exist
| email | admin | member | membership_number |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Feature: As a user
I need to be able to pay my membership fee

Background:
Given the App Configuration is not mocked and is seeded

Given the following users exist
| email | admin | member |
| emma@mutts.com | | false |
Expand Down
2 changes: 1 addition & 1 deletion features/shf-documents/admin-uploads-shf-documents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Feature: Admin uploads meeting PDFs
Given I am on the "new SHF document" page
And I fill in the translated form with data:
| shf_documents.new.title | shf_documents.new.description |
| Uploaded diploma | some description |
| Uploaded tred.exe | some description |
And I choose a shf-document named "tred.exe" to upload
When I click on t("submit") button
Then I should see t("shf_documents.invalid_upload_type")
Expand Down
37 changes: 37 additions & 0 deletions features/step_definitions/app_configuration_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Steps dealing with AdminOnly::AppConfiguration


# This step can be used to make sure that an actual valid
# Application Configuration (AdminOnly::AppConfiguration)
# is used. A valid AppConfiguration is created (all required data is there)
# and all of the methods are called. None of the methods are stubbed.
# This means that Paperclip is likely to be called because the attachments
# are referenced (e.g. the "proof of membership" or some other attached image).
# Because this is a new AppConfiguration, Paperclip will need to create the
# file information for each attachment: the content type, any other image sizes, etc.
# This involves both file I/O, which is slow, and system calls to external
# programs that Paperclip needs to use.
# Thus most of the time tests can and should work with a _mocked_
# AppConfiguration which stubs methods and so none of the Paperclip stuff is
# ever called. (This is set up in the *Before* block in features/support/env.rb )
# But when the feature needs to work with any of the actual AppConfiguration,
# this step should be used.
#
# @example
# Feature: A member pays their membership fee and is approved
#
# Background:
# Given the App Configuration is not mocked and is seeded
#
# Given the following users exist:
# ...
#
# Scenario: .....
#
And(/^the App Configuration is not mocked and is seeded$/) do

# If this has been stubbed (e.g. to use MockAppConfig), unstub it
allow(AdminOnly::AppConfiguration).to receive(:config_to_use).and_call_original

AdminOnly::AppConfiguration.create(email_admin_new_app_received_enabled: false)
end
4 changes: 2 additions & 2 deletions features/step_definitions/assertion_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def get_path(pagename, user = @user)
path = test_exception_notifications_path
when 'admin dashboard'
path = admin_only_dashboard_path
when 'admin edit app configuration'
path = admin_only_edit_app_configuration_path
when 'admin edit app configuration'
path = admin_only_edit_app_configuration_path
when 'admin show app configuration'
path = admin_only_app_configuration_path
end
Expand Down
18 changes: 14 additions & 4 deletions features/step_definitions/navigation_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@

begin
visit path_with_locale(get_path(page, user))
rescue => exception
warn exception.message
rescue StandardError => orig_exception
raise orig_exception # if the original exception

rescue => exception # FIXME -- only do this branch if the path cannot be found. Need to match on the message, not just the exception class Do not swallow (loose) the original exception
# ex: Code above might through a NoMethod exception for some other reason (not having to do with the page path)

warn exception.message # FIXME: what is the purpose of this statement?

begin
path_components = page.split(/\s+/)
visit self.send(path_components.push('path').join('_').to_sym)
rescue NoMethodError, ArgumentError

rescue NoMethodError, ArgumentError => error
raise "Can't find mapping from \"#{page}\" to a path.\n" +
"Now, go and add a mapping in #{__FILE__} or assertion_steps.rb"
"Now, go and add a mapping in #{__FILE__} or assertion_steps.rb\n" +
"original error: #{error}\n" +
"exception: #{exception}\n"

end
end

Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/user_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# ^^ selenium won't find the upload button without visible: false
end

When(/^I choose an SHF "([^"]*)" file named "([^"]*)" to upload$/) do | fieldname, filename |
When(/^I choose an application configuration "([^"]*)" file named "([^"]*)" to upload$/) do | fieldname, filename |
page.attach_file(fieldname,
File.join(Rails.root, 'spec', 'fixtures',
'app_configuration', filename), visible: false)
Expand Down
Loading

0 comments on commit 75f4fa4

Please sign in to comment.