...
 
Commits (10)
......@@ -31,3 +31,6 @@ APP_SECRET_TOKEN='cookies_secret'
# Secret used to prevent cross-site scripting attacks
# with URL store for breadcrumb
GRETEL_TRAILS_SECRET='gretel_secret'
# Google service account Oauth 2.0 client ID for Google
# Calendar synchronization
# GOOGLE_CLIENT_ID=''
......@@ -5,6 +5,6 @@ log/*.log
tmp/
public/system
.DS_Store
vendor/bundle
vendor/bundle*
coverage
.env
......@@ -61,6 +61,8 @@ class MemberGroupsController < ApplicationController
flash[:notice] = "Le groupe de membres a été créé avec succès."
redirect_to @member_group
else
prepare_groups
@selected_members = @member_group.members
flash[:error] = "Une erreur a été rencontrée lors de la création du groupe de membres."
render :action => 'new'
end
......@@ -80,6 +82,8 @@ class MemberGroupsController < ApplicationController
flash[:notice] = 'Groupe de membres mis à jour avec succès.'
redirect_to @member_group
else
prepare_groups
@selected_members = @member_group.members
render :action => "edit"
end
end
......
......@@ -30,7 +30,8 @@ class Email < ActiveRecord::Base
attr_accessible :sender, :recipients_by_contact_types, :other_recipients_enabled, :other_recipients, :novel_attributes, :member_id, :recipients
validates_presence_of :sender, :recipients
validates_presence_of :sender
validates_presence_of :recipients, unless: ->(email) { email.other_recipients.present? }
default_scope :order => "sent_at DESC"
scope :unsent, where(sent_at: nil)
......@@ -95,4 +96,4 @@ class Email < ActiveRecord::Base
recipients ? recipients.gsub(/\s/,'').split(/,/) : []
end
end
\ No newline at end of file
end
......@@ -46,7 +46,7 @@ module GoogleAgenda
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://accounts.google.com/o/oauth2/token',
:scope => 'https://www.googleapis.com/auth/calendar',
:issuer => '477610709683-4rn3impci9hpaltkqc3qrm01dajdoi0j@developer.gserviceaccount.com',
:issuer => ENV['GOOGLE_CLIENT_ID'],
:signing_key => key,
:person => Website.first.gcal_user)
......@@ -66,4 +66,4 @@ module GoogleAgenda
Singleton.send :__init__, self
end
end
end
\ No newline at end of file
end
......@@ -60,6 +60,7 @@
<% end %>
</ul>
<% end %>
<% unless @available_member_groups.empty? %>
<div id="where2practice">
<h2>Où pratiquer :</h2>
<ul>
......@@ -68,4 +69,5 @@
<% end %>
</ul>
</div>
<% end %>
</article>
......@@ -22,7 +22,7 @@
%>
<li>
<label class="checkbox">
<%= check_box_tag "member_group[member_ids][]", member.id, @selected_members.include?(member) %>
<%= check_box_tag "member_group[member_ids][]", member.id, @selected_members.try(:include?, member) %>
<%= member.name %>
</label>
</li>
......@@ -56,4 +56,9 @@ OLIGAA::Application.configure do
# Expands the lines which load the assets
config.assets.debug = true
# For gem mailcatcher
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
end
......@@ -34,6 +34,24 @@ describe Email do
end
it { is_expected.to validate_presence_of(:sender) }
it { is_expected.to validate_presence_of(:sender) }
describe "regarding recipients" do
it "is valid with recipients and other recipients" do
email = build :email
expect(email).to be_valid
end
it "is valid with only recipients" do
email = build :email, other_recipients: nil
expect(email).to be_valid
end
it "is valid with only other recipients" do
email = build :email, recipients: nil
expect(email).to be_valid
end
it "is not valid without recipients nor other recipients" do
email = build :email, recipients: nil, other_recipients: nil
expect(email).not_to be_valid
end
end
end
describe "scopes" do
......@@ -116,4 +134,4 @@ describe Email do
expect(email.all_recipients).to eq(%w[c1@ip.fr c2@ip.fr c3@ip.fr])
end
end
end
\ No newline at end of file
end