-
Notifications
You must be signed in to change notification settings - Fork 313
Join team error #391 #234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Join team error #391 #234
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,6 @@ | |
Rails.application.config.sass.cache_location = "/tmp/codewall-cache/sass/" | ||
|
||
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] | ||
Rails.logger = Logger.new(STDOUT) | ||
Rails.logger.level = Logger::DEBUG | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a cleaner way to enable more verbose output on development? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
config.cache_classes = false | ||
config.whiny_nils = true | ||
config.consider_all_requests_local = true | ||
config.action_dispatch.show_exceptions = false | ||
config.action_dispatch.show_exceptions = true | ||
config.action_controller.allow_forgery_protection = false | ||
config.action_mailer.delivery_method = :test | ||
config.active_support.deprecation = :stderr | ||
|
@@ -13,4 +13,9 @@ | |
|
||
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets | ||
config.assets.allow_debugging = true | ||
|
||
config.middleware.use RackSessionAccess::Middleware # alloes to set session from within Capybara | ||
|
||
Rails.logger = Logger.new(STDOUT) | ||
Rails.logger.level = Logger::DEBUG # provides more verbose output when testing with headless browsers in case of errors | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a cleaner way to enable more verbose output on test? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
require "rails_helper" | ||
|
||
feature "Teams management", js: true do | ||
|
||
background do | ||
login_as(username: 'alice', bypass_ui_login: true) | ||
end | ||
|
||
context 'creating a team with no similar names in db' do | ||
scenario 'create a new team' do | ||
create_team('TEST_TEAM') | ||
expect(page).to have_content('Successfully created a team TEST_TEAM') | ||
end | ||
|
||
scenario 'add user to the newly created team' do | ||
create_team('TEST_TEAM') | ||
|
||
find('section.feature.payment') # ensures that we wait until the create_team action completes | ||
visit '/alice' | ||
|
||
expect(page).to have_content('TEST_TEAM') | ||
end | ||
|
||
scenario 'show payment plans selection' do | ||
create_team('TEST_TEAM') | ||
|
||
expect(page).to have_content('Select a plan and enter payment details to get started') | ||
expect(page).to have_content('FREE') | ||
expect(page).to have_content('MONTHLY') | ||
expect(page).to have_content('ANALYTICS') | ||
end | ||
|
||
scenario 'redirect to team profile page when user selects FREE plan' do | ||
create_team('TEST_TEAM') | ||
find('section.feature.payment').find('.plans .plan.free').click_link 'Select plan' | ||
|
||
team_id = Team.any_of({name: 'TEST_TEAM'}).first.id | ||
expect(current_path).to eq(team_path(team_id)) | ||
end | ||
end | ||
|
||
context 'create a team with similar names already in db' do | ||
let!(:team) { Team.create(name: 'EXISTING_TEAM') } | ||
|
||
scenario 'create a new team' do | ||
create_team('TEAM') | ||
|
||
expect(page).to have_content('We found some matching teams') | ||
expect(page).to have_content('EXISTING_TEAM') | ||
expect(page).to have_content('Select') | ||
expect(page).to have_content('None of the above are my team') | ||
expect(page).to have_content('Create team TEAM') | ||
end | ||
|
||
scenario 'create a new team with originally supplied name' do | ||
create_team('TEAM') | ||
find('.just-create-team').click_link('Create team TEAM') | ||
expect(page).to have_content('Successfully created a team TEAM') | ||
end | ||
|
||
scenario 'attempt to create a team with exact name already in db' do | ||
create_team('EXISTING_TEAM') | ||
find('.just-create-team').click_link('Create team EXISTING_TEAM') | ||
expect(page).to have_content('There was an error in creating a team EXISTING_TEAM') | ||
expect(page).to have_content('Name is already taken') | ||
end | ||
end | ||
|
||
context 'join a team with a similar name' do | ||
let!(:team) { Team.create(name: 'EXISTING_TEAM') } | ||
|
||
scenario 'join an existing team' do | ||
create_team('TEAM') | ||
|
||
find('.results-list').click_link('Select') | ||
|
||
expect(page).to have_content('Select a plan and enter payment details to get started') | ||
expect(page).to have_content('I work at EXISTING_TEAM and just want to join the team') | ||
expect(page).to have_content('Request to join team') | ||
end | ||
|
||
scenario 'request to join a team' do | ||
create_team('TEAM') | ||
|
||
find('.results-list').click_link('Select') | ||
find('section.feature.payment').click_link 'Request to join team' | ||
|
||
expect(current_path).to eq(teamname_path(team.slug)) | ||
expect(page).to have_content('We have submitted your join request to the team admin to approve') | ||
end | ||
end | ||
|
||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
require 'spec_helper.rb' | ||
require 'spec_helper.rb' | ||
require 'capybara/poltergeist' | ||
require 'rack_session_access/capybara' | ||
|
||
Capybara.javascript_driver = :poltergeist | ||
Capybara.default_wait_time = 5 | ||
|
||
RSpec.configure do |config| | ||
config.before(:example, js: :true) do | ||
DatabaseCleaner.strategy = :truncation | ||
ActiveRecord::Base.establish_connection | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. line 11 is magic - it ensures that feature specs do not hang after the first scenario, by somehow helping to switch from |
||
|
||
config.include Features::GeneralHelpers, type: :feature | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is worth adding those, so that devs can have their own local settings. Or is there a better way of doing this?