courier 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'activerecord', "~> 3.0"
4
- gem 'actionpack', "~> 3.0"
3
+ # gem 'activerecord', "~> 3.0"
4
+ # gem 'actionpack', "~> 3.0"
5
+ gem 'rails', '~> 3.0'
5
6
  gem 'state_machine', "~> 0.10.2"
6
7
 
7
8
  # Add dependencies to develop your gem here.
data/README.rdoc CHANGED
@@ -54,6 +54,21 @@ Gemfile:
54
54
 
55
55
  Courier.service(:facebook).deliver_all!
56
56
 
57
+ == Персональные настройки
58
+
59
+ У каждого пользователя есть персональные настройки для матрицы
60
+ шаблон-сервис. По умолчанию они такие, какие указаны в Courier.init
61
+ Установить собственное значение можно так:
62
+
63
+ user.courier.set(:import_complete, :facebook, :on) # или :off
64
+
65
+ Где <tt>:import_complete</tt> - название шаблона, а <tt>:facebook</tt> название сервиса.
66
+
67
+ Узнать значение:
68
+
69
+ user.courier.get(:import_complete, :facebook) # Вернет :on или :off
70
+ user.courier.enabled?(:import_complete, :facebook) # Вернет true или false
71
+
57
72
  == Сервисы
58
73
 
59
74
  На данный момент реализованы сервисы:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.2.0
@@ -0,0 +1,8 @@
1
+ class CourierSettingsController < ApplicationController
2
+ before_filter :authenticate_user!
3
+ respond_to :json
4
+
5
+ def set
6
+ @result = current_user.courier.set!(@template=params[:template], @service=params[:service], params[:value])
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module CourierSettingsHelper
2
+
3
+ def courier_setting_link(user, template, service)
4
+ return image_tag('disabled.png') if user.courier.disabled?(template, service)
5
+
6
+ on = user.courier.on?(template, service)
7
+ icon = image_tag(on ? 'on.png' : 'off.png')
8
+ link_to(icon, courier_settings_set_path(:service=>service, :template=>template,
9
+ :value=>(on ? 'off' : 'on')),
10
+ :remote=>true, 'data-type'=>'html', :class=>:courier_checkbox
11
+ )
12
+ end
13
+ end
@@ -0,0 +1 @@
1
+ = courier_setting_link(current_user, @template, @service)
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do |map|
2
+ get "courier_settings/set"
3
+ end
data/courier.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{courier}
8
- s.version = "0.1.5"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Danil Pismenny"]
12
- s.date = %q{2011-04-02}
12
+ s.date = %q{2011-04-05}
13
13
  s.description = %q{Система управления пользовательскими оповещениями и подписками}
14
14
  s.email = %q{danil@orionet.ru}
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,10 @@ Gem::Specification.new do |s|
25
25
  "README.rdoc",
26
26
  "Rakefile",
27
27
  "VERSION",
28
+ "app/controllers/courier_settings_controller.rb",
29
+ "app/helpers/courier_settings_helper.rb",
30
+ "app/views/courier_settings/set.html.haml",
31
+ "config/routes.rb",
28
32
  "courier.gemspec",
29
33
  "lib/courier.rb",
30
34
  "lib/courier/config.rb",
@@ -40,6 +44,7 @@ Gem::Specification.new do |s|
40
44
  "lib/generators/courier_generator.rb",
41
45
  "lib/generators/templates/courier.rb",
42
46
  "lib/generators/templates/migration.rb",
47
+ "spec/controllers/courier_settings_controller_spec.rb",
43
48
  "spec/courier/config_spec.rb",
44
49
  "spec/courier/message_spec.rb",
45
50
  "spec/courier/owner_setting_spec.rb",
@@ -50,7 +55,9 @@ Gem::Specification.new do |s|
50
55
  "spec/courier/template/base_spec.rb",
51
56
  "spec/courier_spec.rb",
52
57
  "spec/examples/example1_spec.rb",
58
+ "spec/helpers/courier_settings_helper_spec.rb",
53
59
  "spec/spec_helper.rb",
60
+ "spec/support/application_controller.rb",
54
61
  "spec/support/factories.rb",
55
62
  "spec/support/gems_simulation.rb",
56
63
  "spec/support/migration.rb",
@@ -63,6 +70,7 @@ Gem::Specification.new do |s|
63
70
  s.rubygems_version = %q{1.5.0}
64
71
  s.summary = %q{Система управления пользовательскими оповещениями и подписками}
65
72
  s.test_files = [
73
+ "spec/controllers/courier_settings_controller_spec.rb",
66
74
  "spec/courier/config_spec.rb",
67
75
  "spec/courier/message_spec.rb",
68
76
  "spec/courier/owner_setting_spec.rb",
@@ -73,7 +81,9 @@ Gem::Specification.new do |s|
73
81
  "spec/courier/template/base_spec.rb",
74
82
  "spec/courier_spec.rb",
75
83
  "spec/examples/example1_spec.rb",
84
+ "spec/helpers/courier_settings_helper_spec.rb",
76
85
  "spec/spec_helper.rb",
86
+ "spec/support/application_controller.rb",
77
87
  "spec/support/factories.rb",
78
88
  "spec/support/gems_simulation.rb",
79
89
  "spec/support/migration.rb",
@@ -85,8 +95,7 @@ Gem::Specification.new do |s|
85
95
  s.specification_version = 3
86
96
 
87
97
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
88
- s.add_runtime_dependency(%q<activerecord>, ["~> 3.0"])
89
- s.add_runtime_dependency(%q<actionpack>, ["~> 3.0"])
98
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0"])
90
99
  s.add_runtime_dependency(%q<state_machine>, ["~> 0.10.2"])
91
100
  s.add_development_dependency(%q<pg>, [">= 0"])
92
101
  s.add_development_dependency(%q<ruby-debug>, [">= 0"])
@@ -100,8 +109,7 @@ Gem::Specification.new do |s|
100
109
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
101
110
  s.add_development_dependency(%q<rcov>, [">= 0"])
102
111
  else
103
- s.add_dependency(%q<activerecord>, ["~> 3.0"])
104
- s.add_dependency(%q<actionpack>, ["~> 3.0"])
112
+ s.add_dependency(%q<rails>, ["~> 3.0"])
105
113
  s.add_dependency(%q<state_machine>, ["~> 0.10.2"])
106
114
  s.add_dependency(%q<pg>, [">= 0"])
107
115
  s.add_dependency(%q<ruby-debug>, [">= 0"])
@@ -116,8 +124,7 @@ Gem::Specification.new do |s|
116
124
  s.add_dependency(%q<rcov>, [">= 0"])
117
125
  end
118
126
  else
119
- s.add_dependency(%q<activerecord>, ["~> 3.0"])
120
- s.add_dependency(%q<actionpack>, ["~> 3.0"])
127
+ s.add_dependency(%q<rails>, ["~> 3.0"])
121
128
  s.add_dependency(%q<state_machine>, ["~> 0.10.2"])
122
129
  s.add_dependency(%q<pg>, [">= 0"])
123
130
  s.add_dependency(%q<ruby-debug>, [">= 0"])
data/lib/courier.rb CHANGED
@@ -23,11 +23,13 @@ module Courier
23
23
  end
24
24
  end
25
25
 
26
- def template(name)
27
- config.get_template(name)
26
+ def template(key)
27
+ return key if key.is_a?(Courier::Template::Base)
28
+ config.get_template(key)
28
29
  end
29
30
 
30
31
  def service(name)
32
+ return name if name.is_a?(Courier::Service::Base)
31
33
  config.get_service(name)
32
34
  end
33
35
  end
@@ -1,14 +1,19 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  class Courier::Config
4
- attr_accessor :services_hash, :templates_hash, :services_order
4
+ attr_accessor :services_hash, :templates_hash, :services_order, :templates_order
5
5
 
6
6
  def initialize
7
7
  self.services_order=[]
8
8
  self.services_hash={}
9
+ self.templates_order=[]
9
10
  self.templates_hash={}
10
11
  end
11
12
 
13
+ def templates
14
+ templates_order
15
+ end
16
+
12
17
  def services *services
13
18
  return services_order if services.empty?
14
19
  raise 'Список сервисов уже определен' unless services_order.empty?
@@ -32,7 +37,7 @@ class Courier::Config
32
37
  service = services_order[index] or "Too many values (#{index}), no such services"
33
38
  template.set(service, val)
34
39
  end
35
-
40
+ templates_order << template
36
41
  templates_hash[template.name] = template
37
42
  end
38
43
 
data/lib/courier/owner.rb CHANGED
@@ -27,7 +27,7 @@ module Courier::Owner
27
27
  template = Courier.template(template_key)
28
28
  Courier.config.services_order.select do |service|
29
29
  create_courier unless courier
30
- courier.enabled?(template, service, args) and service.message(self, template, args)
30
+ courier.on?(template, service, args) and service.message(self, template, args)
31
31
  end
32
32
  end
33
33
  end
@@ -18,28 +18,57 @@ class Courier::OwnerSetting < ActiveRecord::Base
18
18
  validates_uniqueness_of :owner_id, :scope=>:owner_type
19
19
 
20
20
  def settings_of_template(template)
21
- template = Courier.template(template) if template.is_a? Symbol
21
+ template = Courier.template(template)
22
22
  settings[template.name]||={}
23
23
  end
24
24
 
25
25
  def set(template, service, val=nil)
26
- service = Courier.service(service) if service.is_a? Symbol
26
+ service = Courier.service(service)
27
27
  raise 'Cant use value as argument when block given' if block_given? and val
28
- settings_of_template(template)[service.name] = block_given? ? yield : val
28
+ val = yield if block_given?
29
+ if val.blank?
30
+ settings_of_template(template).delete(service.name)
31
+ nil
32
+ else
33
+ # TODO validate setted value
34
+ settings_of_template(template)[service.name] = val.to_sym
35
+ end
29
36
  end
30
37
 
38
+ def set!(template, service, val=nil)
39
+ if block_given?
40
+ set template, service do
41
+ yield
42
+ end
43
+ else
44
+ set(template, service, val)
45
+ end
46
+ save!
47
+ end
48
+
49
+
31
50
  def get(template, service)
32
- service = Courier.service(service) if service.is_a? Symbol
33
- template = Courier.template(template) if template.is_a? Symbol
51
+ service = Courier.service(service)
52
+ template = Courier.template(template)
53
+ default = template.get(service)
54
+ return :disabled if default==:disabled
34
55
  val = settings_of_template(template)[service.name]
35
- val || template.get(service)
56
+ val || default
36
57
  end
37
58
 
38
- def enabled?(template, service, args={})
59
+ def on?(template, service, args={})
39
60
  get(template, service)==:on
40
61
  end
41
62
 
42
- def disabled?(template, service, args={})
63
+ def off?(template, service, args={})
43
64
  get(template, service)==:off
44
65
  end
66
+
67
+ def disabled?(template, service, args={})
68
+ get(template, service)==:disabled
69
+ end
70
+
71
+ # def enabled?(template, service, args={})
72
+ # get(template, service)!=:disabled
73
+ # end
45
74
  end
@@ -47,6 +47,10 @@ class Courier::Service::Base
47
47
  name
48
48
  end
49
49
 
50
+ def to_label
51
+ I18n::translate(:label, :scope=>[:courier, :services, name] )
52
+ end
53
+
50
54
  def name
51
55
  self.class.name.demodulize.underscore.to_sym
52
56
  end
@@ -18,7 +18,7 @@ class Courier::Service::GritterNotice < Courier::Service::Base
18
18
  #
19
19
 
20
20
  def message(owner, template, options)
21
- scope = [:courier, :gritter_notice]
21
+ scope = [:courier, :services, :gritter_notice]
22
22
  opt = I18n::translate(template.name, :scope=>scope)
23
23
  opt.merge!(options)
24
24
  opt[:text]||=I18n::translate([template.name,:text], opt.merge(:scope=>scope) )
@@ -1,6 +1,8 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  class Courier::Template::Base
3
3
 
4
+ AvailableValues = [:on, :off, :disabled]
5
+
4
6
  attr_accessor :name, :defaults
5
7
 
6
8
  def initialize(args)
@@ -9,7 +11,7 @@ class Courier::Template::Base
9
11
  end
10
12
 
11
13
  def get_text(service, args)
12
- args[:scope]=[:courier, service.to_s] unless args[:scope]
14
+ args[:scope]=[:courier, :services, service.to_s, :templates] unless args[:scope]
13
15
  args[:cascade]=true unless args.has_key? :cascade
14
16
  I18n::translate(name, args )
15
17
  end
@@ -27,7 +29,11 @@ class Courier::Template::Base
27
29
  end
28
30
 
29
31
  def to_s
30
- "Courier::Template(#{name})"
32
+ name.to_s
33
+ end
34
+
35
+ def to_label
36
+ I18n::translate(name, :scope=>[:courier,:templates] )
31
37
  end
32
38
 
33
39
  def key
@@ -37,7 +43,7 @@ class Courier::Template::Base
37
43
  private
38
44
 
39
45
  def check_val(val)
40
- raise "Value must be :on or :off" unless val==:on or val==:off
46
+ raise "Value must be one of #{AvailableValues.join(', ')}" unless AvailableValues.include? val
41
47
  val
42
48
  end
43
49
 
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe CourierSettingsController do
4
+
5
+ before do
6
+ @current_user = Factory :user
7
+ # @request.env["devise.mapping"] = :user
8
+ # sign_in @current_user
9
+ end
10
+ # let(:current_user){ @current_user }
11
+
12
+ describe "GET 'set'" do
13
+ it "should be successful" do
14
+ pending
15
+ courier = double :courier
16
+ courier.should_receive :set!
17
+ controller.current_user.stub('courier') { courier }
18
+ # controller.stub(:url_for)
19
+ get 'set', :service=>:service, :template=>:template, :value=>:on
20
+ response.should be_success
21
+ end
22
+ end
23
+ end
@@ -9,25 +9,50 @@ describe Courier::OwnerSetting do
9
9
  context 'created' do
10
10
  before do
11
11
  @user = Factory :user
12
- Courier.stub(:template) { mock_template :get=>:tralala, :name=>:template_key }
12
+ @service = mock_service :id=>2, :name=>'service1'
13
+ @template = mock_template :get=>:tralala, :name=>:template_key
14
+ Courier.stub(:service) { @service }
15
+ Courier.stub(:template) { @template }
13
16
  end
14
17
 
15
18
  subject { @user.courier }
16
19
  # let(:template) { @template }
17
20
  let(:template_key) { :template_key }
18
- let(:service) { mock_service :id=>2, :name=>'service1' }
21
+ let(:service) { @service }
19
22
 
20
23
  describe '#set and #get' do
21
24
  it 'use default if no set' do
22
25
  subject.get(template_key, service).should == :tralala
23
26
  end
24
27
 
28
+ context 'get on disabled' do
29
+ before do
30
+ @template.stub(:get) { :disabled }
31
+ subject.set(template_key, service, :on)
32
+ end
33
+ it{ subject.get(template_key, service).should == :disabled }
34
+ it { subject.on?(template_key, service).should be_false }
35
+ end
36
+
37
+ context 'set to nil' do
38
+ before do
39
+ subject.set(template_key, service, nil)
40
+ end
41
+ specify 'remove service' do
42
+ subject.settings[:template_key].should_not include(service.name)
43
+ end
44
+ it 'uses default' do
45
+ subject.get(template_key, service).should == :tralala
46
+ end
47
+ it { subject.on?(template_key, service).should be_false }
48
+ end
49
+
25
50
  context ':on as block' do
26
51
  before do
27
52
  subject.set(template_key, service) { :on }
28
53
  end
29
54
  it { subject.get(template_key, service).should == :on }
30
- it { subject.enabled?(template_key, service).should be_true }
55
+ it { subject.on?(template_key, service).should be_true }
31
56
  end
32
57
 
33
58
  context ':off as argument' do
@@ -35,8 +60,8 @@ describe Courier::OwnerSetting do
35
60
  subject.set(template_key, service, :off)
36
61
  end
37
62
  it { subject.get(template_key, service).should == :off }
38
- it { subject.disabled?(template_key, service).should be_true }
39
- it { subject.enabled?(template_key, service).should be_false }
63
+ it { subject.off?(template_key, service).should be_true }
64
+ it { subject.on?(template_key, service).should be_false }
40
65
  end
41
66
  end
42
67
  end
@@ -13,7 +13,7 @@ describe User, "Courier::Owner extention" do
13
13
  describe '#message' do
14
14
  let(:args) { {:level=>123, :text=>'some text'} }
15
15
  subject{ Factory :user }
16
- it 'should send message to enabled services only' do
16
+ it 'should send message to turned on services only' do
17
17
  template = mock_template
18
18
 
19
19
  service1 = mock_service
@@ -22,7 +22,7 @@ describe User, "Courier::Owner extention" do
22
22
 
23
23
  subject.should_not_receive :create_courier
24
24
 
25
- subject.courier.should_receive(:enabled?).twice { |template, service, args|
25
+ subject.courier.should_receive(:on?).twice { |template, service, args|
26
26
  service==service1
27
27
  }
28
28
 
@@ -16,6 +16,8 @@ describe Courier::Service::Base do
16
16
  end
17
17
  end
18
18
 
19
+ its(:to_label) { should == 'translation missing: en.courier.services.base.label' }
20
+
19
21
  # inherited in subclasses
20
22
  describe '#deliver!' do
21
23
  end
@@ -7,7 +7,7 @@ describe Courier::Service::GritterNotice do
7
7
  args={:a=>1}
8
8
  owner = double
9
9
  template = double :name=>:template_key
10
- I18n.should_receive(:translate).with(template.name, :scope=>[:courier, :gritter_notice]) {{:text=>'text of translation', :level=>:warning} }
10
+ I18n.should_receive(:translate).with(template.name, :scope=>[:courier, :services, :gritter_notice]) {{:text=>'text of translation', :level=>:warning} }
11
11
  owner.should_receive(:gritter_notice).with(template.name, {:text=>"text of translation", :a=>1, :level=>:warning})
12
12
  subject.message owner, template, args
13
13
  end
@@ -12,7 +12,7 @@ describe Courier::Template::Base do
12
12
  subject.should_receive(:name) { 'template_key' }
13
13
  subject.
14
14
  get_text(mock_service(:to_s=>'facebook'), :some_option=>123).should ==
15
- 'translation missing: en.courier.facebook.template_key'
15
+ 'translation missing: en.courier.services.facebook.templates.template_key'
16
16
  end
17
17
  end
18
18
 
@@ -6,7 +6,7 @@ describe 'Initialize Courier' do
6
6
  d.services :active_mailer, :gritter_notice, :facebook
7
7
  d.template :import_complete, :off, :on, :off
8
8
  d.template :avatar_loaded, :on, :off, :on
9
- d.template :weekly_subscription, :on, :on, :on
9
+ d.template :weekly_subscription, :on, :on, :disabled
10
10
  end
11
11
  end
12
12
 
@@ -24,7 +24,7 @@ describe 'Initialize Courier' do
24
24
 
25
25
  Courier.template(:weekly_subscription).get(:active_mailer).should == :on
26
26
  Courier.template(:weekly_subscription).get(:gritter_notice).should == :on
27
- Courier.template(:weekly_subscription).get(:facebook).should == :on
27
+ Courier.template(:weekly_subscription).get(:facebook).should == :disabled
28
28
  end
29
29
 
30
30
  describe 'users settings' do
@@ -42,20 +42,20 @@ describe 'Initialize Courier' do
42
42
 
43
43
  user.courier.get(:weekly_subscription, :active_mailer).should == :on
44
44
  user.courier.get(:weekly_subscription, :gritter_notice).should == :on
45
- user.courier.get(:weekly_subscription, :facebook).should == :on
45
+ user.courier.get(:weekly_subscription, :facebook).should == :disabled
46
46
  end
47
47
 
48
48
  describe 'override' do
49
49
  before do
50
50
  user.courier.set(:import_complete, :active_mailer, :on)
51
51
  user.courier.set(:avatar_loaded, :active_mailer, :off)
52
- user.courier.set(:weekly_subscription, :active_mailer, :on)
52
+ user.courier.set(:weekly_subscription, :facebook, :on)
53
53
  end
54
54
 
55
55
  specify 'users default settings are equal to system' do
56
56
  user.courier.get(:import_complete, :active_mailer).should == :on
57
57
  user.courier.get(:avatar_loaded, :active_mailer).should == :off
58
- user.courier.get(:weekly_subscription, :active_mailer).should == :on
58
+ user.courier.get(:weekly_subscription, :facebook).should == :disabled
59
59
  end
60
60
  end
61
61
  end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe CourierSettingsHelper do
4
+ let!(:user) { Factory :user }
5
+ let(:template) { mock_template }
6
+ let(:service) { mock_service }
7
+
8
+ # include ActionView::Helpers::TagHelper
9
+ # include ActionView::Helpers::UrlHelper
10
+ # include Rails.application.routes.url_helpers
11
+
12
+ it 'should return disabled icon when disabled' do
13
+ courier = double :courier
14
+ courier.should_receive(:disabled?) { true }
15
+ user.stub(:courier) { courier }
16
+ helper.should_receive(:image_tag).with('disabled.png')
17
+
18
+ helper.courier_setting_link(user, template, service)
19
+ end
20
+
21
+ it "should return 'on' icon when is on" do
22
+ courier = double :courier
23
+ courier.should_receive(:disabled?) { false }
24
+ courier.should_receive(:on?) { true }
25
+ user.stub(:courier) { courier }
26
+ helper.stub(:courier_settings_set_path)
27
+ helper.stub(:link_to)
28
+
29
+ helper.should_receive(:image_tag).with('on.png')
30
+ helper.courier_setting_link(user, template, service)
31
+ end
32
+
33
+ it "should return 'on' icon when is on" do
34
+ courier = double :courier
35
+ courier.should_receive(:disabled?) { false }
36
+ courier.should_receive(:on?) { false }
37
+ user.stub(:courier) { courier }
38
+ helper.stub(:courier_settings_set_path)
39
+ helper.stub(:link_to)
40
+
41
+ helper.should_receive(:image_tag).with('off.png')
42
+ helper.courier_setting_link(user, template, service)
43
+ end
44
+
45
+ end
data/spec/spec_helper.rb CHANGED
@@ -4,9 +4,8 @@ require "bundler/setup"
4
4
 
5
5
  ENV["RAILS_ENV"] ||= 'test'
6
6
 
7
- require 'active_record'
8
- require 'action_view'
9
- require 'action_controller'
7
+ require 'rails/all'
8
+
10
9
  require 'state_machine'
11
10
 
12
11
  require 'rspec'
@@ -14,18 +13,13 @@ require 'rspec/rails'
14
13
  require 'shoulda'
15
14
  require 'factory_girl'
16
15
 
17
- # require 'nulldb_rspec'
18
- # include NullDB::RSpec::NullifiedDatabase
19
-
20
16
  ActiveRecord::Base.establish_connection(
21
17
  :adapter => 'sqlite3',
22
18
  :database => ":memory:"
23
- # :adapter => 'postgresql',
24
- # :database => "courier_test"
25
19
 
26
20
  )
27
21
 
28
- #ActiveRecord::Base.logger = Logger.new(File.open('log/database.log', 'a'))
22
+ class Application < Rails::Application; end
29
23
 
30
24
  require 'lib/generators/templates/migration'
31
25
  CreateCourierTables.migrate :up
@@ -40,6 +34,10 @@ require 'courier'
40
34
 
41
35
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
42
36
 
37
+ require 'config/routes'
38
+ require 'app/controllers/courier_settings_controller'
39
+ require 'app/helpers/courier_settings_helper'
40
+
43
41
  RSpec.configure do |config|
44
42
  config.use_transactional_fixtures = true
45
43
  config.use_transactional_examples = true
@@ -0,0 +1,7 @@
1
+ class ApplicationController < ActionController::Base
2
+ def authenticate_user!
3
+ end
4
+
5
+ def current_user
6
+ end
7
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: courier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 5
10
- version: 0.1.5
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Danil Pismenny
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-02 00:00:00 +04:00
18
+ date: 2011-04-05 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: activerecord
22
+ name: rails
23
23
  version_requirements: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
@@ -33,24 +33,9 @@ dependencies:
33
33
  prerelease: false
34
34
  type: :runtime
35
35
  requirement: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: actionpack
38
- version_requirements: &id002 !ruby/object:Gem::Requirement
39
- none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 7
44
- segments:
45
- - 3
46
- - 0
47
- version: "3.0"
48
- prerelease: false
49
- type: :runtime
50
- requirement: *id002
51
36
  - !ruby/object:Gem::Dependency
52
37
  name: state_machine
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
38
+ version_requirements: &id002 !ruby/object:Gem::Requirement
54
39
  none: false
55
40
  requirements:
56
41
  - - ~>
@@ -63,10 +48,10 @@ dependencies:
63
48
  version: 0.10.2
64
49
  prerelease: false
65
50
  type: :runtime
66
- requirement: *id003
51
+ requirement: *id002
67
52
  - !ruby/object:Gem::Dependency
68
53
  name: pg
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
70
55
  none: false
71
56
  requirements:
72
57
  - - ">="
@@ -77,10 +62,10 @@ dependencies:
77
62
  version: "0"
78
63
  prerelease: false
79
64
  type: :development
80
- requirement: *id004
65
+ requirement: *id003
81
66
  - !ruby/object:Gem::Dependency
82
67
  name: ruby-debug
83
- version_requirements: &id005 !ruby/object:Gem::Requirement
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
84
69
  none: false
85
70
  requirements:
86
71
  - - ">="
@@ -91,10 +76,10 @@ dependencies:
91
76
  version: "0"
92
77
  prerelease: false
93
78
  type: :development
94
- requirement: *id005
79
+ requirement: *id004
95
80
  - !ruby/object:Gem::Dependency
96
81
  name: watchr
97
- version_requirements: &id006 !ruby/object:Gem::Requirement
82
+ version_requirements: &id005 !ruby/object:Gem::Requirement
98
83
  none: false
99
84
  requirements:
100
85
  - - ">="
@@ -105,10 +90,10 @@ dependencies:
105
90
  version: "0"
106
91
  prerelease: false
107
92
  type: :development
108
- requirement: *id006
93
+ requirement: *id005
109
94
  - !ruby/object:Gem::Dependency
110
95
  name: sqlite3
111
- version_requirements: &id007 !ruby/object:Gem::Requirement
96
+ version_requirements: &id006 !ruby/object:Gem::Requirement
112
97
  none: false
113
98
  requirements:
114
99
  - - ">="
@@ -119,10 +104,10 @@ dependencies:
119
104
  version: "0"
120
105
  prerelease: false
121
106
  type: :development
122
- requirement: *id007
107
+ requirement: *id006
123
108
  - !ruby/object:Gem::Dependency
124
109
  name: factory_girl
125
- version_requirements: &id008 !ruby/object:Gem::Requirement
110
+ version_requirements: &id007 !ruby/object:Gem::Requirement
126
111
  none: false
127
112
  requirements:
128
113
  - - ">="
@@ -133,10 +118,10 @@ dependencies:
133
118
  version: "0"
134
119
  prerelease: false
135
120
  type: :development
136
- requirement: *id008
121
+ requirement: *id007
137
122
  - !ruby/object:Gem::Dependency
138
123
  name: shoulda
139
- version_requirements: &id009 !ruby/object:Gem::Requirement
124
+ version_requirements: &id008 !ruby/object:Gem::Requirement
140
125
  none: false
141
126
  requirements:
142
127
  - - ">="
@@ -147,10 +132,10 @@ dependencies:
147
132
  version: "0"
148
133
  prerelease: false
149
134
  type: :development
150
- requirement: *id009
135
+ requirement: *id008
151
136
  - !ruby/object:Gem::Dependency
152
137
  name: rspec
153
- version_requirements: &id010 !ruby/object:Gem::Requirement
138
+ version_requirements: &id009 !ruby/object:Gem::Requirement
154
139
  none: false
155
140
  requirements:
156
141
  - - ~>
@@ -162,10 +147,10 @@ dependencies:
162
147
  version: "2.5"
163
148
  prerelease: false
164
149
  type: :development
165
- requirement: *id010
150
+ requirement: *id009
166
151
  - !ruby/object:Gem::Dependency
167
152
  name: rspec-rails
168
- version_requirements: &id011 !ruby/object:Gem::Requirement
153
+ version_requirements: &id010 !ruby/object:Gem::Requirement
169
154
  none: false
170
155
  requirements:
171
156
  - - ">="
@@ -176,10 +161,10 @@ dependencies:
176
161
  version: "0"
177
162
  prerelease: false
178
163
  type: :development
179
- requirement: *id011
164
+ requirement: *id010
180
165
  - !ruby/object:Gem::Dependency
181
166
  name: bundler
182
- version_requirements: &id012 !ruby/object:Gem::Requirement
167
+ version_requirements: &id011 !ruby/object:Gem::Requirement
183
168
  none: false
184
169
  requirements:
185
170
  - - ~>
@@ -192,10 +177,10 @@ dependencies:
192
177
  version: 1.0.0
193
178
  prerelease: false
194
179
  type: :development
195
- requirement: *id012
180
+ requirement: *id011
196
181
  - !ruby/object:Gem::Dependency
197
182
  name: jeweler
198
- version_requirements: &id013 !ruby/object:Gem::Requirement
183
+ version_requirements: &id012 !ruby/object:Gem::Requirement
199
184
  none: false
200
185
  requirements:
201
186
  - - ~>
@@ -208,10 +193,10 @@ dependencies:
208
193
  version: 1.5.2
209
194
  prerelease: false
210
195
  type: :development
211
- requirement: *id013
196
+ requirement: *id012
212
197
  - !ruby/object:Gem::Dependency
213
198
  name: rcov
214
- version_requirements: &id014 !ruby/object:Gem::Requirement
199
+ version_requirements: &id013 !ruby/object:Gem::Requirement
215
200
  none: false
216
201
  requirements:
217
202
  - - ">="
@@ -222,7 +207,7 @@ dependencies:
222
207
  version: "0"
223
208
  prerelease: false
224
209
  type: :development
225
- requirement: *id014
210
+ requirement: *id013
226
211
  description: !binary |
227
212
  0KHQuNGB0YLQtdC80LAg0YPQv9GA0LDQstC70LXQvdC40Y8g0L/QvtC70YzQ
228
213
  t9C+0LLQsNGC0LXQu9GM0YHQutC40LzQuCDQvtC/0L7QstC10YnQtdC90LjR
@@ -245,6 +230,10 @@ files:
245
230
  - README.rdoc
246
231
  - Rakefile
247
232
  - VERSION
233
+ - app/controllers/courier_settings_controller.rb
234
+ - app/helpers/courier_settings_helper.rb
235
+ - app/views/courier_settings/set.html.haml
236
+ - config/routes.rb
248
237
  - courier.gemspec
249
238
  - lib/courier.rb
250
239
  - lib/courier/config.rb
@@ -260,6 +249,7 @@ files:
260
249
  - lib/generators/courier_generator.rb
261
250
  - lib/generators/templates/courier.rb
262
251
  - lib/generators/templates/migration.rb
252
+ - spec/controllers/courier_settings_controller_spec.rb
263
253
  - spec/courier/config_spec.rb
264
254
  - spec/courier/message_spec.rb
265
255
  - spec/courier/owner_setting_spec.rb
@@ -270,7 +260,9 @@ files:
270
260
  - spec/courier/template/base_spec.rb
271
261
  - spec/courier_spec.rb
272
262
  - spec/examples/example1_spec.rb
263
+ - spec/helpers/courier_settings_helper_spec.rb
273
264
  - spec/spec_helper.rb
265
+ - spec/support/application_controller.rb
274
266
  - spec/support/factories.rb
275
267
  - spec/support/gems_simulation.rb
276
268
  - spec/support/migration.rb
@@ -315,6 +307,7 @@ summary: !binary |
315
307
  j9C80Lgg0Lgg0L/QvtC00L/QuNGB0LrQsNC80Lg=
316
308
 
317
309
  test_files:
310
+ - spec/controllers/courier_settings_controller_spec.rb
318
311
  - spec/courier/config_spec.rb
319
312
  - spec/courier/message_spec.rb
320
313
  - spec/courier/owner_setting_spec.rb
@@ -325,7 +318,9 @@ test_files:
325
318
  - spec/courier/template/base_spec.rb
326
319
  - spec/courier_spec.rb
327
320
  - spec/examples/example1_spec.rb
321
+ - spec/helpers/courier_settings_helper_spec.rb
328
322
  - spec/spec_helper.rb
323
+ - spec/support/application_controller.rb
329
324
  - spec/support/factories.rb
330
325
  - spec/support/gems_simulation.rb
331
326
  - spec/support/migration.rb