Spec tidying

This commit is contained in:
Prommah 2015-11-07 06:21:31 +00:00
parent b55ff01ff5
commit dd899cddb0
10 changed files with 35 additions and 35 deletions

4
spec/factories/article.rb Normal file → Executable file
View file

@ -1,6 +1,6 @@
FactoryGirl.define do
factory :article do
sequence(:title) { |n| "Article #{n}" }
sequence(:text) { |n| (0..100).map{ (0...8).map { (65 + rand(26)).chr }.join }.join(" ") }
sequence(:text) { (0..100).map { (0...8).map { (65 + rand(26)).chr }.join }.join(" ") }
end
end
end

6
spec/factories/ban.rb Normal file → Executable file
View file

@ -1,13 +1,13 @@
FactoryGirl.define do
factory :ban do
ban_type Ban::TYPE_SITE
expiry Date.today + 1
expiry Time.now.utc.to_date + 1
# Hack because of the awkward way bans are created (requires user_name)
before(:create) do |ban|
if ban.user.nil?
user = create :user
ban.user_name = user.username
else
else
ban.user_name = ban.user.username
end
end
@ -28,4 +28,4 @@ FactoryGirl.define do
trait :expired do
expiry Date.yesterday - 1
end
end
end

6
spec/factories/category.rb Normal file → Executable file
View file

@ -5,10 +5,10 @@ FactoryGirl.define do
end
trait :news do
domain Category::DOMAIN_NEWS
domain Category::DOMAIN_NEWS
end
trait :game do
domain Category::DOMAIN_GAMES
domain Category::DOMAIN_GAMES
end
end
end

4
spec/factories/gather.rb Normal file → Executable file
View file

@ -4,10 +4,10 @@ FactoryGirl.define do
end
trait :running do
status Gather::STATE_RUNNING
status Gather::STATE_RUNNING
end
trait :picking do
status Gather::STATE_PICKING
status Gather::STATE_PICKING
end
end

8
spec/factories/grouper.rb Normal file → Executable file
View file

@ -1,5 +1,5 @@
FactoryGirl.define do
factory :grouper do
sequence(:task) { |n| "Task#{n}" }
end
end
factory :grouper do
sequence(:task) { |n| "Task#{n}" }
end
end

14
spec/factories/issue.rb Normal file → Executable file
View file

@ -1,8 +1,8 @@
FactoryGirl.define do
factory :issue do
sequence(:title) { |n| "Issue title #{n}" }
sequence(:text) { |n| "Issue Text #{n}" }
status Issue::STATUS_OPEN
association :author, factory: :user
end
end
factory :issue do
sequence(:title) { |n| "Issue title #{n}" }
sequence(:text) { |n| "Issue Text #{n}" }
status Issue::STATUS_OPEN
association :author, factory: :user
end
end

16
spec/factories/message.rb Normal file → Executable file
View file

@ -1,9 +1,9 @@
FactoryGirl.define do
factory :message do
association :sender, factory: :user
association :recipient, factory: :user
sequence(:text) { |n| "text-#{n}" }
sequence(:title) { |n| "title-#{n}" }
sequence(:text_parsed) { |n| "text-#{n}" }
end
end
factory :message do
association :sender, factory: :user
association :recipient, factory: :user
sequence(:text) { |n| "text-#{n}" }
sequence(:title) { |n| "title-#{n}" }
sequence(:text_parsed) { |n| "text-#{n}" }
end
end

2
spec/factories/server.rb Normal file → Executable file
View file

@ -13,4 +13,4 @@ FactoryGirl.define do
active false
end
end
end
end

4
spec/factories/team.rb Normal file → Executable file
View file

@ -1,11 +1,11 @@
FactoryGirl.define do
factory :team do
sequence(:name) { |n| "Team ##{n}" }
irc "#team"
web "http://team.com"
tag "[TEAM]"
country "EU"
comment "We are a team"
end
end
end

6
spec/models/user_spec.rb Normal file → Executable file
View file

@ -22,7 +22,7 @@
# salt :string(255)
#
require 'spec_helper'
require "spec_helper"
describe User do
let!(:user) { create :user }
@ -34,7 +34,7 @@ describe User do
it "returns true if user is banned" do
Ban.create!(ban_type: Ban::TYPE_SITE,
expiry: Time.now + 10.days,
expiry: Time.now.utc + 10.days,
user_name: user.username)
expect(user.banned?).to be_truthy
@ -42,7 +42,7 @@ describe User do
it "returns true for specific bans" do
Ban.create!(ban_type: Ban::TYPE_MUTE,
expiry: Time.now + 10.days,
expiry: Time.now.utc + 10.days,
user_name: user.username)
expect(user.banned? Ban::TYPE_MUTE).to be_truthy