-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
13 changed files
with
150 additions
and
17 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
--require spec_helper | ||
--format documentation |
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
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
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
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
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
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
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,11 @@ | ||
require 'rails_helper' | ||
RSpec.describe ArticlesCategory, type: :model do | ||
describe 'assosiations' do | ||
it { should belong_to(:article)} | ||
it { should belong_to(:category)} | ||
end | ||
describe 'Articles Categories attributes presence' do | ||
it { should validate_presence_of(:article_id) } | ||
it { should validate_presence_of(:category_id) } | ||
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,36 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Article, type: :model do | ||
describe 'assosiations' do | ||
it { should belong_to(:user) } | ||
it { should have_many(:votes) } | ||
it { should have_one_attached(:image) } | ||
it { should have_many(:articles_categories) } | ||
|
||
end | ||
describe 'title presence' do | ||
it { should validate_presence_of(:title) } | ||
end | ||
|
||
describe 'text presence' do | ||
it { should validate_presence_of(:text) } | ||
end | ||
|
||
|
||
|
||
describe 'category ids presence' do | ||
it { should validate_presence_of(:category_ids) } | ||
end | ||
describe 'image presence' do | ||
it { should validate_presence_of(:image) } | ||
end | ||
|
||
describe 'lenght of title' do | ||
it { should validate_length_of(:title) } | ||
end | ||
describe 'lenght of text' do | ||
it { should validate_length_of(:text) } | ||
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,14 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Category, type: :model do | ||
|
||
describe 'assosiations' do | ||
it{should have_many (:articles_categories)} | ||
it{should have_many (:articles)} | ||
end | ||
|
||
describe 'Category attributes presence' do | ||
it {should validate_presence_of (:name)} | ||
it {should validate_presence_of (:priority)} | ||
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 User, type: :model do | ||
|
||
subject(:user) { User.new(username: '7aves', name: 'Gustave', email: '[email protected]', password: "example") } | ||
|
||
describe 'assosiations' do | ||
it {should have_many(:articles)} | ||
it {should have_many(:votes)} | ||
end | ||
describe 'valid atributes' do | ||
it 'is valid with all attributes' do | ||
expect(user).to be_valid | ||
end | ||
it 'is not valid without a name' do | ||
user.name = nil | ||
expect(user).to_not be_valid | ||
end | ||
it 'is not valid without a username' do | ||
user.username = nil | ||
expect(user).to_not be_valid | ||
end | ||
it 'is not valid without a email' do | ||
user.email = nil | ||
expect(user).to_not be_valid | ||
end | ||
it 'is not valid without a password' do | ||
user.password = nil | ||
expect(user).to_not be_valid | ||
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,12 @@ | ||
require 'rails_helper' | ||
RSpec.describe Vote, type: :model do | ||
|
||
describe 'assosiations' do | ||
it { should belong_to(:article)} | ||
it { should belong_to(:user)} | ||
end | ||
describe 'vote attributes presence' do | ||
it { should validate_presence_of(:article_id) } | ||
it { should validate_presence_of(:user_id) } | ||
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