Ability to give a statement

This commit is contained in:
2017-04-13 17:16:03 +02:00
parent b30bd91f3d
commit dd5e22ea48
66 changed files with 812 additions and 25 deletions
+7
View File
@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :publicity do
organisation { Faker::Company.name }
statement { Faker::Lorem.paragraph }
avatar { File.new("#{Rails.root}/spec/support/fixtures/image.jpg") }
end
end
+14
View File
@@ -0,0 +1,14 @@
FactoryGirl.define do
factory :supporter do
email { Faker::Internet.email }
password { Faker::Lorem.words(8).join }
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
street { Faker::Address.street_name }
zip { Faker::Address.zip }
city { Faker::Address.city }
support { %w(signer supporter).sample }
age_category { %w(underage young middle retired).sample }
language { %w(de fr it).sample }
end
end
+41
View File
@@ -0,0 +1,41 @@
require 'rails_helper'
feature 'Publicity' do
let(:supporter) { create :supporter }
before { sign_in(supporter) }
scenario 'User makes his announcement public' do
visit root_path
click_link 'Meine Unterstützung öffentlich kundtun ...'
fill_in 'Organisation', with: 'Schweizer Volkspartei'
fill_in 'Statement', with: 'Wir wollen ja eigentlich nur das Volk verarschen ;)'
attach_file('publicity_avatar', "#{Rails.root}/spec/support/fixtures/image.jpg")
click_button 'Zur Überprüfung einsenden'
expect(page).to have_content 'Besten Dank die Daten werden überprüft.'
end
scenario 'User makes changes announcement' do
create :publicity, supporter: supporter
visit root_path
click_link 'Statement neu einreichen'
fill_in 'Organisation', with: 'Schweizer Volkspartei'
fill_in 'Statement', with: 'Wir wollen ja eigentlich nur das Volk verarschen ;)'
attach_file('publicity_avatar', "#{Rails.root}/spec/support/fixtures/image.jpg")
click_button 'Zur Überprüfung einsenden'
expect(page).to have_content 'Besten Dank die Daten werden überprüft.'
expect(page).to have_content 'Die Veröffentlichung wurde noch nicht genehmigt'
end
end
+1 -1
View File
@@ -1,6 +1,6 @@
require 'rails_helper'
feature 'Support announcement' do
feature 'Support' do
scenario 'User announces support' do
visit root_path
+9
View File
@@ -0,0 +1,9 @@
require 'rails_helper'
describe Publicity do
it { is_expected.to be_embedded_in(:supporter) }
it { is_expected.to validate_presence_of(:state) }
it { is_expected.to validate_presence_of(:statement) }
it { is_expected.to validate_presence_of(:avatar) }
end
+2
View File
@@ -12,6 +12,8 @@ describe Supporter do
it { is_expected.to validate_presence_of(:age_category) }
it { is_expected.to validate_presence_of(:language) }
it { is_expected.to embed_one(:publicity) }
describe '.counter' do
it 'counts only from a certain number on' do
allow(Supporter).to receive(:count) { 12 }
+10
View File
@@ -16,6 +16,16 @@ Bundler.require(*Rails.groups)
RSpec.configure do |config|
config.include Mongoid::Matchers, type: :model
config.include FactoryGirl::Syntax::Methods
config.before(:suite) do
FactoryGirl.find_definitions
end
config.include Devise::Test::ControllerHelpers, type: :controller
config.include Devise::Test::ControllerHelpers, type: :view
config.include Devise::Test::IntegrationHelpers, type: :feature
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
# assertions if you prefer.
Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB