Skip to content
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

move all login method to macros #712

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions spec/controllers/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,4 @@
expect(page_analysis.pages.size).to be >= 3
end
end

def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end
7 changes: 0 additions & 7 deletions spec/features/email_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,4 @@
expect(page.find('#email_subject').value).to eq(@template.subject)
expect(page.find('#email_content').value).to eq(@template.content)
end


def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end
6 changes: 0 additions & 6 deletions spec/features/event_draft_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,4 @@
visit events_path
expect(page).to_not have_text(@event.name)
end

def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end
6 changes: 0 additions & 6 deletions spec/features/events_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,4 @@
expect(page).to have_every_text(not_accepted_names)
expect(page).to have_no_text(accepted_names)
end

def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end
12 changes: 0 additions & 12 deletions spec/features/participants_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@
expect(page.body).to contain_ordered(expected_order.reverse)

end

def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end

RSpec.feature "Event participants overview", :type => :feature do
Expand Down Expand Up @@ -123,10 +117,4 @@ def login(role)
expect{click_button I18n.t('emails.email_form.send')}.to change{ActionMailer::Base.deliveries.count}.by(0)
expect(page).to have_text(I18n.t('emails.submit.sending_failed'))
end

def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end
6 changes: 0 additions & 6 deletions spec/features/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,4 @@
expect(page).to have_text(max2.profile.last_name)
expect(page).to_not have_text(user3.profile.last_name)
end

def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end
1 change: 1 addition & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
config.include Warden::Test::Helpers
config.include Devise::Test::ControllerHelpers, :type => :controller
config.include Devise::Test::ControllerHelpers, :type => :view
config.include LoginMacros, type: :feature

# Reset warden after each test
config.after :each do
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
# Skip PhantomJS tests if PhantomJS is not installed.
config.filter_run_excluding :js => (not Cliver::detect('phantomjs'))

# load custom matchers
Dir[File.dirname(__FILE__) + "/support/matchers/*.rb"].each {|f| require f}
# load custom matchers and helpers
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

# Use color not only in STDOUT but also in pagers and files
# config.tty = true
Expand Down
7 changes: 7 additions & 0 deletions spec/support/login_macros.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module LoginMacros
def login(role)
@profile = FactoryGirl.create(:profile)
@profile.user.role = role
login_as(@profile.user, :scope => :user)
end
end