Skip to content

Instantly share code, notes, and snippets.

@gen1321
Created April 29, 2016 12:42
Show Gist options
  • Save gen1321/df74207fc8d04054b69a2ff81a5c84ea to your computer and use it in GitHub Desktop.
Save gen1321/df74207fc8d04054b69a2ff81a5c84ea to your computer and use it in GitHub Desktop.
require 'rails_helper'
describe "the signin process", :type => :feature do
before :each do
AdminUser.create(:email => 'user@example.com', :password => 'password')
end
let(:sign_in) { visit '/admin'
within("#session_new") do
fill_in 'Email', :with => 'user@example.com'
fill_in 'Password', :with => 'password'
end
click_button 'Login'
}
let(:create_publisher) { sign_in
visit '/admin/publishers/new'
within("#new_publisher") do
fill_in "Email", :with => 'test@example.com'
fill_in "publisher_password", :with => 'asdasdasd'
fill_in "publisher_password_confirmation", :with => 'asdasdasd'
end
click_button 'Create Publisher' }
let(:create_channel) {
sign_in
visit '/admin/channels/new'
within("#new_channel") do
fill_in "Name", :with => 'Test'
fill_in "Template", :with => 'asdasdasd'
fill_in "History template", :with => 'asdasdasd'
fill_in "History delay", :with => '1'
select "hours", :from => 'Delay unit'
end
click_button 'Create Channel'
}
let(:create_member) {
sign_in
visit 'admin/members/new'
within("#new_member") do
fill_in "Email", :with => 'test@example.com'
end
click_button 'Create Member'
}
let(:create_subscription){
sign_in
create_member
create_channel
visit '/admin/subscriptions/new'
select 'Test' , :from =>'Channel'
select 'test@example.com' , :from =>'Member'
click_button 'Create Subscription'
}
it "Signs me in" do
sign_in
expect(page).to have_content 'Signed in successfully.'
end
it "Signs me out" do
sign_in
click_link 'Logout'
expect(page).to have_content 'Login'
end
#Publisher
it "Creates a new publisher" do
create_publisher
end
it "Delete publisher" do
create_publisher
click_link 'Delete Publisher'
expect(page).to have_content 'Publisher was successfully destroyed.'
end
it "Get list of publishers" do
sign_in
create_publisher
visit '/admin/publishers'
expect(page).to have_content 'test@example.com'
end
#Channel
it "Creates a new channel" do
create_channel
expect(page).to have_content 'Channel was successfully created.'
end
it "Delete a channel" do
create_channel
click_link 'Delete Channel'
expect(page).to have_content 'Channel was successfully destroyed.'
end
it "Get list of channels" do
sign_in
create_channel
visit('/admin/channels')
expect(page).to have_content('Test')
end
#Member
it "Create a new Member" do
create_member
expect(page).to have_content 'Member was successfully created.'
end
it "Delete a Member" do
create_member
click_link 'Delete Member'
expect(page).to have_content 'Member was successfully destroyed.'
end
it "Get list of Members" do
sign_in
create_member
visit '/admin/members'
expect(page).to have_content 'test@example.com'
end
#Subscription
it "Create a new Subscription" do
create_subscription
expect(page).to have_content 'Subscription was successfully created.'
end
it "Delete a Subscription" do
create_subscription
click_link 'Delete Subscription'
expect(page).to have_content 'Subscription was successfully destroyed.'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment