-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7a8a47
commit bbbbd4e
Showing
4 changed files
with
90 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Group, type: :model do | ||
|
||
test_user = User.create!(name: 'peter robert', email: '[email protected]', password: 'hsjoarty067') | ||
test_group = Group.create!(name: 'test_group', icon: 'https://testicons.com/testicon.png', user_id:test_user.id) | ||
|
||
|
||
it 'should fail to create a group without name' do | ||
ev = Group.create(icon: 'https://testicons.com/testicon.png') | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
|
||
it 'should fail to create a group user' do | ||
ev = Group.create(name: 'test_group',icon: 'https://testicons.com/testicon.png') | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
|
||
it 'should create group' do | ||
ev = Group.create(name: 'test_group',icon: 'https://testicons.com/testicon.png', user_id:test_user.id) | ||
expect(ev.persisted?).to eql(true) | ||
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Transaction, type: :model do | ||
|
||
test_user = User.create!(name: 'peter robert', email: '[email protected]', password: 'hsjoarty067') | ||
test_group = test_user.groups.create!(name: 'test_group', icon: 'https://testicons.com/testicon.png') | ||
test_transaction = Transaction.create!(name: 'test_transaction', amount: 100, user_id: test_user.id, group_id: test_group.id) | ||
|
||
|
||
it 'should fail to create a transaction without amount' do | ||
ev = Transaction.create(name: 'test event') | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
|
||
it 'should fail to create a transaction without name' do | ||
ev = Transaction.create(amount: 200) | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
|
||
it 'should fail to create a transaction without user' do | ||
ev = Transaction.create(name: 'test event', amount: 100, group_id: test_group.id ) | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
|
||
it 'should be saved with all users' do | ||
ev = Transaction.create(name: 'test event', amount: 100, user_id: test_user.id, group_id: test_group.id ) | ||
expect(ev.persisted?).to eql(true) | ||
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,19 +1,24 @@ | ||
RSpec.describe User, type: :model do | ||
context 'validation tests' do | ||
it 'ensures name presence' do | ||
|
||
end | ||
require 'rails_helper' | ||
|
||
it 'ensures email presence' do | ||
|
||
end | ||
RSpec.describe User, type: :model do | ||
|
||
it 'ensures password presence' do | ||
|
||
test_user = User.create!(name: 'peter robert', email: '[email protected]', password: 'hsjoarty067') | ||
|
||
it 'should fail to create account without name' do | ||
ev = User.create(email: '[email protected]', password: 'hsjoarty067') | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
|
||
it 'ensures confirm password presence' do | ||
it 'should fail to create account without email' do | ||
ev = User.create(name: 'peter robert', password: 'hsjoarty067') | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
|
||
it 'should fail to create account without password' do | ||
ev = User.create(name: 'peter robert', email: '[email protected]') | ||
expect(ev.persisted?).to eql(false) | ||
end | ||
end | ||
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
RSpec.configure do |config| | ||
config.before(:suite) do | ||
DatabaseCleaner.clean_with :truncation, except: %w[ar_internal_metadata] | ||
end | ||
|
||
config.before(:each) do | ||
DatabaseCleaner.strategy = :transaction | ||
end | ||
|
||
config.before(:each) do | ||
DatabaseCleaner.start | ||
end | ||
|
||
config.after(:each) do | ||
DatabaseCleaner.clean | ||
end | ||
end |