email_manager 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.0.6
2
+
3
+ * Fixed pagination on the managed emails page
4
+ * Updated routes to match rails standard routing
5
+ * Added a working dummy app to the project and got the testing working again
6
+
1
7
  == 0.0.5
2
8
 
3
9
  * Removed find_by calls to work better with rails 3.1
data/Gemfile CHANGED
@@ -1,9 +1,10 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ gem "rails", ">= 3.0.0"
4
+
3
5
  # Add dependencies to develop your gem here.
4
6
  # Include everything needed to run rake, tests, features, etc.
5
7
  group :development, :test do
6
- gem "rails", ">= 3.0.0"
7
8
  gem "sqlite3"
8
9
  gem "rspec", "~> 2.6.0"
9
10
  gem "rspec-rails"
@@ -13,8 +14,6 @@ group :development, :test do
13
14
 
14
15
  gem "bundler", "~> 1.0.0"
15
16
  gem "jeweler", "~> 1.6.3"
16
- # not sure if rcov works for ruby 1.9
17
- gem "rcov", ">= 0"
18
17
  # trying cover me instead
19
18
  gem "cover_me", ">= 1.0.0.rc6"
20
19
  # hudson ci
@@ -1,97 +1,104 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- abstract (1.0.0)
5
- actionmailer (3.0.7)
6
- actionpack (= 3.0.7)
7
- mail (~> 2.2.19)
8
- actionpack (3.0.7)
9
- activemodel (= 3.0.7)
10
- activesupport (= 3.0.7)
11
- builder (~> 2.1.2)
12
- erubis (~> 2.6.6)
13
- i18n (~> 0.5.0)
14
- rack (~> 1.2.1)
15
- rack-mount (~> 0.6.14)
16
- rack-test (~> 0.5.7)
17
- tzinfo (~> 0.3.23)
18
- activemodel (3.0.7)
19
- activesupport (= 3.0.7)
20
- builder (~> 2.1.2)
21
- i18n (~> 0.5.0)
22
- activerecord (3.0.7)
23
- activemodel (= 3.0.7)
24
- activesupport (= 3.0.7)
25
- arel (~> 2.0.10)
26
- tzinfo (~> 0.3.23)
27
- activeresource (3.0.7)
28
- activemodel (= 3.0.7)
29
- activesupport (= 3.0.7)
30
- activesupport (3.0.7)
4
+ actionmailer (3.2.6)
5
+ actionpack (= 3.2.6)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.6)
8
+ activemodel (= 3.2.6)
9
+ activesupport (= 3.2.6)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.6)
18
+ activesupport (= 3.2.6)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.6)
21
+ activemodel (= 3.2.6)
22
+ activesupport (= 3.2.6)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.6)
26
+ activemodel (= 3.2.6)
27
+ activesupport (= 3.2.6)
28
+ activesupport (3.2.6)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ addressable (2.2.8)
31
32
  archive-tar-minitar (0.5.2)
32
- arel (2.0.10)
33
- builder (2.1.2)
34
- capybara (1.0.0)
33
+ arel (3.0.2)
34
+ builder (3.0.0)
35
+ capybara (1.1.2)
35
36
  mime-types (>= 1.16)
36
37
  nokogiri (>= 1.3.3)
37
38
  rack (>= 1.0.0)
38
39
  rack-test (>= 0.5.4)
39
- selenium-webdriver (~> 0.2.0)
40
+ selenium-webdriver (~> 2.0)
40
41
  xpath (~> 0.1.4)
41
- childprocess (0.1.9)
42
+ childprocess (0.3.3)
42
43
  ffi (~> 1.0.6)
43
- ci_reporter (1.6.5)
44
+ ci_reporter (1.7.0)
44
45
  builder (>= 2.1.2)
45
- columnize (0.3.4)
46
- configatron (2.8.2)
46
+ columnize (0.3.6)
47
+ configatron (2.9.1)
47
48
  yamler (>= 0.1.0)
48
- cover_me (1.1.0)
49
+ cover_me (1.2.0)
49
50
  configatron
50
51
  hashie
51
- diff-lcs (1.1.2)
52
- erubis (2.6.6)
53
- abstract (>= 1.0.0)
54
- ffi (1.0.9)
52
+ diff-lcs (1.1.3)
53
+ erubis (2.7.0)
54
+ ffi (1.0.11)
55
55
  git (1.2.5)
56
- hashie (1.0.0)
57
- i18n (0.5.0)
58
- jeweler (1.6.3)
56
+ hashie (1.2.0)
57
+ hike (1.2.1)
58
+ i18n (0.6.0)
59
+ jeweler (1.6.4)
59
60
  bundler (~> 1.0)
60
61
  git (>= 1.2.5)
61
62
  rake
62
- json_pure (1.5.3)
63
+ journey (1.0.4)
64
+ json (1.7.3)
65
+ libwebsocket (0.1.3)
66
+ addressable
63
67
  linecache19 (0.5.12)
64
68
  ruby_core_source (>= 0.1.4)
65
- mail (2.2.19)
66
- activesupport (>= 2.3.6)
69
+ mail (2.4.4)
67
70
  i18n (>= 0.4.0)
68
71
  mime-types (~> 1.16)
69
72
  treetop (~> 1.4.8)
70
- mime-types (1.16)
71
- nokogiri (1.5.0)
72
- polyglot (0.3.1)
73
- rack (1.2.3)
74
- rack-mount (0.6.14)
75
- rack (>= 1.0.0)
76
- rack-test (0.5.7)
73
+ mime-types (1.19)
74
+ multi_json (1.3.6)
75
+ nokogiri (1.5.5)
76
+ polyglot (0.3.3)
77
+ rack (1.4.1)
78
+ rack-cache (1.2)
79
+ rack (>= 0.4)
80
+ rack-ssl (1.3.2)
81
+ rack
82
+ rack-test (0.6.1)
77
83
  rack (>= 1.0)
78
- rails (3.0.7)
79
- actionmailer (= 3.0.7)
80
- actionpack (= 3.0.7)
81
- activerecord (= 3.0.7)
82
- activeresource (= 3.0.7)
83
- activesupport (= 3.0.7)
84
+ rails (3.2.6)
85
+ actionmailer (= 3.2.6)
86
+ actionpack (= 3.2.6)
87
+ activerecord (= 3.2.6)
88
+ activeresource (= 3.2.6)
89
+ activesupport (= 3.2.6)
84
90
  bundler (~> 1.0)
85
- railties (= 3.0.7)
86
- railties (3.0.7)
87
- actionpack (= 3.0.7)
88
- activesupport (= 3.0.7)
91
+ railties (= 3.2.6)
92
+ railties (3.2.6)
93
+ actionpack (= 3.2.6)
94
+ activesupport (= 3.2.6)
95
+ rack-ssl (~> 1.3.2)
89
96
  rake (>= 0.8.7)
90
97
  rdoc (~> 3.4)
91
- thor (~> 0.14.4)
92
- rake (0.9.2)
93
- rcov (0.9.9)
94
- rdoc (3.8)
98
+ thor (< 2.0, >= 0.14.6)
99
+ rake (0.9.2.2)
100
+ rdoc (3.12)
101
+ json (~> 1.4)
95
102
  rspec (2.6.0)
96
103
  rspec-core (~> 2.6.0)
97
104
  rspec-expectations (~> 2.6.0)
@@ -115,17 +122,23 @@ GEM
115
122
  ruby-debug-base19 (>= 0.11.19)
116
123
  ruby_core_source (0.1.5)
117
124
  archive-tar-minitar (>= 0.5.2)
118
- rubyzip (0.9.4)
119
- selenium-webdriver (0.2.2)
120
- childprocess (>= 0.1.9)
121
- ffi (>= 1.0.7)
122
- json_pure
125
+ rubyzip (0.9.9)
126
+ selenium-webdriver (2.24.0)
127
+ childprocess (>= 0.2.5)
128
+ libwebsocket (~> 0.1.3)
129
+ multi_json (~> 1.0)
123
130
  rubyzip
124
- sqlite3 (1.3.3)
125
- thor (0.14.6)
126
- treetop (1.4.9)
131
+ sprockets (2.1.3)
132
+ hike (~> 1.2)
133
+ rack (~> 1.0)
134
+ tilt (!= 1.3.0, ~> 1.1)
135
+ sqlite3 (1.3.6)
136
+ thor (0.15.4)
137
+ tilt (1.3.3)
138
+ treetop (1.4.10)
139
+ polyglot
127
140
  polyglot (>= 0.3.1)
128
- tzinfo (0.3.29)
141
+ tzinfo (0.3.33)
129
142
  xpath (0.1.4)
130
143
  nokogiri (~> 1.3)
131
144
  yamler (0.1.0)
@@ -141,7 +154,6 @@ DEPENDENCIES
141
154
  cover_me (>= 1.0.0.rc6)
142
155
  jeweler (~> 1.6.3)
143
156
  rails (>= 3.0.0)
144
- rcov
145
157
  rspec (~> 2.6.0)
146
158
  rspec-rails
147
159
  ruby-debug19
data/Rakefile CHANGED
@@ -28,20 +28,24 @@ Jeweler::Tasks.new do |gem|
28
28
  end
29
29
  Jeweler::RubygemsDotOrgTasks.new
30
30
 
31
- # rspec tests
32
- require 'rake/rdoctask'
33
31
  require 'rspec/core'
34
32
  require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new(:spec) do |spec|
34
+ spec.pattern = FileList['spec/**/*_spec.rb']
35
+ end
35
36
 
36
- RSpec::Core::RakeTask.new(:spec)
37
-
38
- Rake::RDocTask.new(:rdoc) do |rdoc|
39
- rdoc.rdoc_dir = 'rdoc'
40
- rdoc.title = 'EmailManager'
41
- rdoc.options << '--line-numbers' << '--inline-source'
42
- rdoc.rdoc_files.include('README.rdoc')
43
- rdoc.rdoc_files.include('lib/**/*.rb')
37
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
38
+ spec.pattern = 'spec/**/*_spec.rb'
39
+ spec.rcov = true
44
40
  end
41
+
42
+ # Rake::RDocTask.new(:rdoc) do |rdoc|
43
+ # rdoc.rdoc_dir = 'rdoc'
44
+ # rdoc.title = 'EmailManager'
45
+ # rdoc.options << '--line-numbers' << '--inline-source'
46
+ # rdoc.rdoc_files.include('README.rdoc')
47
+ # rdoc.rdoc_files.include('lib/**/*.rb')
48
+ # end
45
49
  # end rspec tests
46
50
 
47
51
  require 'yard'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -3,7 +3,7 @@
3
3
  # Includes optional support for meta_search and kaminari gems
4
4
  # @author Jeremiah Hemphill
5
5
  module EmailManager
6
- class ManagedEmailsController < ApplicationController
6
+ class ManagedEmailsController < ::ApplicationController
7
7
  unloadable
8
8
 
9
9
  # shows all managed emails with pagination and sorting
@@ -20,10 +20,9 @@ module EmailManager
20
20
 
21
21
  # Paginate with kaminari
22
22
  begin
23
- @managed_emails = Kaminari.paginate_array(@search.each).page(params[:page])
23
+ @managed_emails = Kaminari.paginate_array(@search.all).page(params[:page])
24
24
  @pagination_enabled = true
25
25
  rescue NameError => e
26
- puts e
27
26
  @managed_emails = @search
28
27
  @pagination_enabled = false
29
28
  end
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= render "search_form", :locals => { :search => @search, :search_enabled => @search_enabled }%>
6
6
  <div class='content'>
7
- <%= render "pagination", :locals => { :records => @records, :pagniation_enabled => @pagination_enabled }%>
7
+ <%= render "pagination", :locals => { :records => @managed_emails, :pagination_enabled => @pagination_enabled }%>
8
8
  <table class='tableview'>
9
9
  <tr>
10
10
  <th>To</th>
@@ -3,7 +3,7 @@
3
3
 
4
4
  = render "search_form", :locals => { :search => @search, :search_enabled => @search_enabled }
5
5
  %div.content
6
- = render "pagination", :locals => { :records => @records, :pagniation_enabled => @pagination_enabled }
6
+ = render "pagination", :locals => { :records => @managed_emails, :pagination_enabled => @pagination_enabled }
7
7
  %table.tableview
8
8
  %tr
9
9
  %th To
@@ -43,7 +43,7 @@
43
43
  <p>
44
44
  <b>Body:</b>
45
45
  <br />
46
- <iframe width = "600" height = "512" src = "<%= email_manager_managed_email_body_path(@managed_email) %>" >
46
+ <iframe width = "600" height = "512" src = "<%= body_email_manager_managed_email_path(@managed_email) %>" >
47
47
  <p>
48
48
  Your browser does not support iframes.
49
49
  </p>
@@ -32,7 +32,7 @@
32
32
  %p
33
33
  %b Body:
34
34
  %br
35
- %iframe{ :width => "600", :height => "512", :src => "#{email_manager_managed_email_body_path(@managed_email)}" }
35
+ %iframe{ :width => "600", :height => "512", :src => "#{body_email_manager_managed_email_path(@managed_email)}" }
36
36
  %p
37
37
  Your browser does not support iframes.
38
38
  = @managed_email.body
@@ -1,8 +1,11 @@
1
1
  # Adds routes for the three controller methods to the parent project
2
2
  Rails.application.routes.draw do
3
3
  namespace :email_manager do
4
- match "managed_emails", :to => "managed_emails#index", :as => "managed_emails"
5
- match "managed_email/:id", :to => "managed_emails#show", :as => "managed_email", :method => :get
6
- match "managed_email/:id/body", :to => "managed_emails#body", :as => "managed_email_body", :method => :get
4
+ resources :managed_emails, :only => [:index, :show] do
5
+ member do
6
+ get :body
7
+ end
8
+ end
9
+ root :to => "managed_emails#index", :as => :root
7
10
  end
8
11
  end
@@ -46,6 +46,10 @@ describe EmailManager::ManagedEmailsController do
46
46
  [@managed_email]
47
47
  end
48
48
  end
49
+ @search = []
50
+ @search.stub(:all).and_return(@search)
51
+ EmailManager::ManagedEmail.stub(:search).and_return(@search)
52
+
49
53
  Kaminari.should_receive(:paginate_array).and_return(Kaminari.new)
50
54
  get :index
51
55
  assigns[:pagination_enabled].should be_true
@@ -60,7 +64,7 @@ describe EmailManager::ManagedEmailsController do
60
64
  describe "show" do
61
65
  before(:each) do
62
66
  @managed_email = mock_model(EmailManager::ManagedEmail)
63
- EmailManager::ManagedEmail.stub!(:find).with(1).and_return(@managed_email)
67
+ EmailManager::ManagedEmail.stub!(:find).with("1").and_return(@managed_email)
64
68
  end
65
69
 
66
70
  def do_show
@@ -88,7 +92,7 @@ describe EmailManager::ManagedEmailsController do
88
92
  @managed_email = mock_model(EmailManager::ManagedEmail)
89
93
  @managed_email_body = "The body of the mocked email"
90
94
  @managed_email.stub!(:body).and_return(@managed_email_body)
91
- EmailManager::ManagedEmail.stub!(:find).with(1).and_return(@managed_email)
95
+ EmailManager::ManagedEmail.stub!(:find).with("1").and_return(@managed_email)
92
96
  end
93
97
 
94
98
  def do_body
@@ -11,7 +11,7 @@ Dummy::Application.configure do
11
11
 
12
12
  # Show full error reports and disable caching
13
13
  config.consider_all_requests_local = true
14
- config.action_view.debug_rjs = true
14
+ # config.action_view.debug_rjs = true
15
15
  config.action_controller.perform_caching = false
16
16
 
17
17
  # Don't care if the mailer can't send
@@ -4,4 +4,4 @@
4
4
  # If you change this key, all old signed cookies will become invalid!
5
5
  # Make sure the secret is at least 30 characters and all random,
6
6
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '34556ae9dcdb2eab08ea7c64037e57e9b4d8b9768482e000f11b0244a9940f7508581683361a3ebbdfd8913d7a62b133ce4678f5a5ac6f4986d84a818115da57'
7
+ Dummy::Application.config.secret_token = '4839d0c7acaaefb520461da03ab7f6058d3036f1d7753517ef283fc7616ab74818b4db0760149c9b0909690ecf1b74a319263a40d1e4f5a4d0066acba47491aa'
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20120629144404) do
15
+
16
+ create_table "managed_emails", :force => true do |t|
17
+ t.datetime "date_sent"
18
+ t.text "from"
19
+ t.text "reply_to"
20
+ t.text "to"
21
+ t.text "cc"
22
+ t.text "bcc"
23
+ t.text "headers"
24
+ t.string "message_id"
25
+ t.text "subject"
26
+ t.text "body"
27
+ t.text "caller"
28
+ t.datetime "created_at", :null => false
29
+ t.datetime "updated_at", :null => false
30
+ end
31
+
32
+ end
@@ -1,4 +1,14 @@
1
1
  (function() {
2
+ Ajax.Responders.register({
3
+ onCreate: function(request) {
4
+ var token = $$('meta[name=csrf-token]')[0];
5
+ if (token) {
6
+ if (!request.options.requestHeaders) request.options.requestHeaders = {};
7
+ request.options.requestHeaders['X-CSRF-Token'] = token.readAttribute('content');
8
+ }
9
+ }
10
+ });
11
+
2
12
  // Technique from Juriy Zaytsev
3
13
  // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
4
14
  function isEventSupported(eventName) {
@@ -14,33 +24,33 @@
14
24
  }
15
25
 
16
26
  function isForm(element) {
17
- return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
27
+ return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM';
18
28
  }
19
29
 
20
30
  function isInput(element) {
21
31
  if (Object.isElement(element)) {
22
- var name = element.nodeName.toUpperCase()
23
- return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
32
+ var name = element.nodeName.toUpperCase();
33
+ return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA';
24
34
  }
25
- else return false
35
+ else return false;
26
36
  }
27
37
 
28
38
  var submitBubbles = isEventSupported('submit'),
29
- changeBubbles = isEventSupported('change')
39
+ changeBubbles = isEventSupported('change');
30
40
 
31
41
  if (!submitBubbles || !changeBubbles) {
32
42
  // augment the Event.Handler class to observe custom events when needed
33
43
  Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
34
44
  function(init, element, eventName, selector, callback) {
35
- init(element, eventName, selector, callback)
45
+ init(element, eventName, selector, callback);
36
46
  // is the handler being attached to an element that doesn't support this event?
37
47
  if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
38
48
  (!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
39
49
  // "submit" => "emulated:submit"
40
- this.eventName = 'emulated:' + this.eventName
50
+ this.eventName = 'emulated:' + this.eventName;
41
51
  }
42
52
  }
43
- )
53
+ );
44
54
  }
45
55
 
46
56
  if (!submitBubbles) {
@@ -49,26 +59,26 @@
49
59
  // special handler for the real "submit" event (one-time operation)
50
60
  if (!form.retrieve('emulated:submit')) {
51
61
  form.on('submit', function(submitEvent) {
52
- var emulated = form.fire('emulated:submit', submitEvent, true)
62
+ var emulated = form.fire('emulated:submit', submitEvent, true);
53
63
  // if custom event received preventDefault, cancel the real one too
54
- if (emulated.returnValue === false) submitEvent.preventDefault()
55
- })
56
- form.store('emulated:submit', true)
64
+ if (emulated.returnValue === false) submitEvent.preventDefault();
65
+ });
66
+ form.store('emulated:submit', true);
57
67
  }
58
- })
68
+ });
59
69
  }
60
70
 
61
71
  if (!changeBubbles) {
62
72
  // discover form inputs on the page
63
- document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
73
+ document.on('focusin', 'input, select, textarea', function(focusEvent, input) {
64
74
  // special handler for real "change" events
65
75
  if (!input.retrieve('emulated:change')) {
66
76
  input.on('change', function(changeEvent) {
67
- input.fire('emulated:change', changeEvent, true)
68
- })
69
- input.store('emulated:change', true)
77
+ input.fire('emulated:change', changeEvent, true);
78
+ });
79
+ input.store('emulated:change', true);
70
80
  }
71
- })
81
+ });
72
82
  }
73
83
 
74
84
  function handleRemote(element) {
@@ -80,7 +90,10 @@
80
90
  if (element.tagName.toLowerCase() === 'form') {
81
91
  method = element.readAttribute('method') || 'post';
82
92
  url = element.readAttribute('action');
83
- params = element.serialize();
93
+ // serialize the form with respect to the submit button that was pressed
94
+ params = element.serialize({ submit: element.retrieve('rails:submit-button') });
95
+ // clear the pressed submit button information
96
+ element.store('rails:submit-button', null);
84
97
  } else {
85
98
  method = element.readAttribute('data-method') || 'get';
86
99
  url = element.readAttribute('href');
@@ -92,14 +105,19 @@
92
105
  parameters: params,
93
106
  evalScripts: true,
94
107
 
95
- onComplete: function(request) { element.fire("ajax:complete", request); },
96
- onSuccess: function(request) { element.fire("ajax:success", request); },
97
- onFailure: function(request) { element.fire("ajax:failure", request); }
108
+ onCreate: function(response) { element.fire("ajax:create", response); },
109
+ onComplete: function(response) { element.fire("ajax:complete", response); },
110
+ onSuccess: function(response) { element.fire("ajax:success", response); },
111
+ onFailure: function(response) { element.fire("ajax:failure", response); }
98
112
  });
99
113
 
100
114
  element.fire("ajax:after");
101
115
  }
102
116
 
117
+ function insertHiddenField(form, name, value) {
118
+ form.insert(new Element('input', { type: 'hidden', name: name, value: value }));
119
+ }
120
+
103
121
  function handleMethod(element) {
104
122
  var method = element.readAttribute('data-method'),
105
123
  url = element.readAttribute('href'),
@@ -107,85 +125,78 @@
107
125
  csrf_token = $$('meta[name=csrf-token]')[0];
108
126
 
109
127
  var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
110
- element.parentNode.insert(form);
128
+ $(element.parentNode).insert(form);
111
129
 
112
130
  if (method !== 'post') {
113
- var field = new Element('input', { type: 'hidden', name: '_method', value: method });
114
- form.insert(field);
131
+ insertHiddenField(form, '_method', method);
115
132
  }
116
133
 
117
134
  if (csrf_param) {
118
- var param = csrf_param.readAttribute('content'),
119
- token = csrf_token.readAttribute('content'),
120
- field = new Element('input', { type: 'hidden', name: param, value: token });
121
- form.insert(field);
135
+ insertHiddenField(form, csrf_param.readAttribute('content'), csrf_token.readAttribute('content'));
122
136
  }
123
137
 
124
138
  form.submit();
125
139
  }
126
140
 
141
+ function disableFormElements(form) {
142
+ form.select('input[type=submit][data-disable-with]').each(function(input) {
143
+ input.store('rails:original-value', input.getValue());
144
+ input.setValue(input.readAttribute('data-disable-with')).disable();
145
+ });
146
+ }
147
+
148
+ function enableFormElements(form) {
149
+ form.select('input[type=submit][data-disable-with]').each(function(input) {
150
+ input.setValue(input.retrieve('rails:original-value')).enable();
151
+ });
152
+ }
127
153
 
128
- document.on("click", "*[data-confirm]", function(event, element) {
154
+ function allowAction(element) {
129
155
  var message = element.readAttribute('data-confirm');
130
- if (!confirm(message)) event.stop();
131
- });
156
+ return !message || confirm(message);
157
+ }
158
+
159
+ document.on('click', 'a[data-confirm], a[data-remote], a[data-method]', function(event, link) {
160
+ if (!allowAction(link)) {
161
+ event.stop();
162
+ return false;
163
+ }
132
164
 
133
- document.on("click", "a[data-remote]", function(event, element) {
134
- if (event.stopped) return;
135
- handleRemote(element);
136
- event.stop();
165
+ if (link.readAttribute('data-remote')) {
166
+ handleRemote(link);
167
+ event.stop();
168
+ } else if (link.readAttribute('data-method')) {
169
+ handleMethod(link);
170
+ event.stop();
171
+ }
137
172
  });
138
173
 
139
- document.on("click", "a[data-method]", function(event, element) {
140
- if (event.stopped) return;
141
- handleMethod(element);
142
- event.stop();
174
+ document.on("click", "form input[type=submit], form button[type=submit], form button:not([type])", function(event, button) {
175
+ // register the pressed submit button
176
+ event.findElement('form').store('rails:submit-button', button.name || false);
143
177
  });
144
178
 
145
179
  document.on("submit", function(event) {
146
- var element = event.findElement(),
147
- message = element.readAttribute('data-confirm');
148
- if (message && !confirm(message)) {
180
+ var form = event.findElement();
181
+
182
+ if (!allowAction(form)) {
149
183
  event.stop();
150
184
  return false;
151
185
  }
152
186
 
153
- var inputs = element.select("input[type=submit][data-disable-with]");
154
- inputs.each(function(input) {
155
- input.disabled = true;
156
- input.writeAttribute('data-original-value', input.value);
157
- input.value = input.readAttribute('data-disable-with');
158
- });
159
-
160
- var element = event.findElement("form[data-remote]");
161
- if (element) {
162
- handleRemote(element);
187
+ if (form.readAttribute('data-remote')) {
188
+ handleRemote(form);
163
189
  event.stop();
190
+ } else {
191
+ disableFormElements(form);
164
192
  }
165
193
  });
166
194
 
167
- document.on("ajax:after", "form", function(event, element) {
168
- var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
169
- inputs.each(function(input) {
170
- input.value = input.readAttribute('data-original-value');
171
- input.removeAttribute('data-original-value');
172
- input.disabled = false;
173
- });
195
+ document.on('ajax:create', 'form', function(event, form) {
196
+ if (form == event.findElement()) disableFormElements(form);
174
197
  });
175
-
176
- Ajax.Responders.register({
177
- onCreate: function(request) {
178
- var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
179
-
180
- if (csrf_meta_tag) {
181
- var header = 'X-CSRF-Token',
182
- token = csrf_meta_tag.readAttribute('content');
183
-
184
- if (!request.options.requestHeaders) {
185
- request.options.requestHeaders = {};
186
- }
187
- request.options.requestHeaders[header] = token;
188
- }
189
- }
198
+
199
+ document.on('ajax:complete', 'form', function(event, form) {
200
+ if (form == event.findElement()) enableFormElements(form);
190
201
  });
191
202
  })();
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe EmailManager do
4
- it "should be valid" do
5
- EmailManager.should be_a(Module)
3
+ describe "EmailManager" do
4
+ it "fails" do
5
+ #fail "hey buddy, you should probably rename this file and start specing for real"
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe EmailManager::ManagedEmailObserver do
4
4
  describe "deliver_email" do
5
5
  before(:each) do
6
- DummyMailer.deliver_dummy_email_notification
6
+ DummyMailer.dummy_email_notification.deliver
7
7
  end
8
8
 
9
9
  it "should only store the calling file of the email if it is in /app" do
@@ -2,16 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  describe EmailManager::ManagedEmailsController do
4
4
  describe "routes" do
5
+ it "recognizes and generates root" do
6
+ email_manager_root_path.should == "/email_manager"
7
+ end
8
+
5
9
  it "recognizes and generates #index" do
6
10
  email_manager_managed_emails_path.should == "/email_manager/managed_emails"
7
11
  end
8
12
 
9
13
  it "recognizes and generates #show" do
10
- email_manager_managed_email_path(1).should == "/email_manager/managed_email/1"
14
+ email_manager_managed_email_path(1).should == "/email_manager/managed_emails/1"
11
15
  end
12
16
 
13
17
  it "recognizes and generates #body" do
14
- email_manager_managed_email_body_path(1).should == "/email_manager/managed_email/1/body"
18
+ body_email_manager_managed_email_path(1).should == "/email_manager/managed_emails/1/body"
15
19
  end
16
20
  end
17
21
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: email_manager
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeremiah Hemphill
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-04-06 00:00:00 Z
13
+ date: 2012-06-29 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -20,7 +20,7 @@ dependencies:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.0.0
23
- type: :development
23
+ type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: *id001
26
26
  - !ruby/object:Gem::Dependency
@@ -111,20 +111,9 @@ dependencies:
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
115
- name: rcov
116
- requirement: &id010 !ruby/object:Gem::Requirement
117
- none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
122
- type: :development
123
- prerelease: false
124
- version_requirements: *id010
125
114
  - !ruby/object:Gem::Dependency
126
115
  name: cover_me
127
- requirement: &id011 !ruby/object:Gem::Requirement
116
+ requirement: &id010 !ruby/object:Gem::Requirement
128
117
  none: false
129
118
  requirements:
130
119
  - - ">="
@@ -132,10 +121,10 @@ dependencies:
132
121
  version: 1.0.0.rc6
133
122
  type: :development
134
123
  prerelease: false
135
- version_requirements: *id011
124
+ version_requirements: *id010
136
125
  - !ruby/object:Gem::Dependency
137
126
  name: ci_reporter
138
- requirement: &id012 !ruby/object:Gem::Requirement
127
+ requirement: &id011 !ruby/object:Gem::Requirement
139
128
  none: false
140
129
  requirements:
141
130
  - - ">="
@@ -143,7 +132,7 @@ dependencies:
143
132
  version: "0"
144
133
  type: :development
145
134
  prerelease: false
146
- version_requirements: *id012
135
+ version_requirements: *id011
147
136
  description: System for storing and managing emails sent by ActionMailer
148
137
  email: jeremiah@cloudspace.com
149
138
  executables: []
@@ -174,7 +163,6 @@ files:
174
163
  - app/views/email_manager/managed_emails/show.html.erb
175
164
  - app/views/email_manager/managed_emails/show.html.haml
176
165
  - config/routes.rb
177
- - email_manager.gemspec
178
166
  - lib/email_manager.rb
179
167
  - lib/email_manager/engine.rb
180
168
  - lib/email_manager/managed_email_observer.rb
@@ -183,8 +171,8 @@ files:
183
171
  - lib/generators/email_manager/templates/migrations/install.rb
184
172
  - lib/generators/email_manager/upgrade_generator.rb
185
173
  - lib/generators/email_manager/views_generator.rb
186
- - reload.sh
187
- - spec/controllers/managed_emails_controller_spec.rb
174
+ - log/test.log
175
+ - spec/controllers/email_manager/managed_emails_controller_spec.rb
188
176
  - spec/dummy/Rakefile
189
177
  - spec/dummy/app/controllers/application_controller.rb
190
178
  - spec/dummy/app/helpers/application_helper.rb
@@ -207,9 +195,8 @@ files:
207
195
  - spec/dummy/config/initializers/session_store.rb
208
196
  - spec/dummy/config/locales/en.yml
209
197
  - spec/dummy/config/routes.rb
210
- - spec/dummy/db/migrate/20110706133041_install_email_manager.rb
211
- - spec/dummy/db/test.sqlite3
212
- - spec/dummy/log/server.log
198
+ - spec/dummy/db/migrate/20120629144404_install_email_manager.rb
199
+ - spec/dummy/db/schema.rb
213
200
  - spec/dummy/public/404.html
214
201
  - spec/dummy/public/422.html
215
202
  - spec/dummy/public/500.html
@@ -223,9 +210,8 @@ files:
223
210
  - spec/dummy/public/stylesheets/.gitkeep
224
211
  - spec/dummy/script/rails
225
212
  - spec/email_manager_spec.rb
226
- - spec/integration/navigation_spec.rb
227
213
  - spec/managed_email_observer_spec.rb
228
- - spec/models/managed_email_spec.rb
214
+ - spec/models/email_manager/managed_email_spec.rb
229
215
  - spec/routing/managed_emails_spec.rb
230
216
  - spec/spec_helper.rb
231
217
  homepage: https://github.com/jeremiahishere/email_manager
@@ -241,7 +227,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
227
  requirements:
242
228
  - - ">="
243
229
  - !ruby/object:Gem::Version
244
- hash: 46700724754865621
230
+ hash: -2306597727014822815
245
231
  segments:
246
232
  - 0
247
233
  version: "0"
@@ -1,146 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "email_manager"
8
- s.version = "0.0.5"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Jeremiah Hemphill"]
12
- s.date = "2012-04-06"
13
- s.description = "System for storing and managing emails sent by ActionMailer"
14
- s.email = "jeremiah@cloudspace.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "CHANGELOG",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE.txt",
26
- "README.rdoc",
27
- "Rakefile",
28
- "VERSION",
29
- "app/controllers/email_manager/managed_emails_controller.rb",
30
- "app/models/email_manager/managed_email.rb",
31
- "app/views/email_manager/managed_emails/_pagination.html.erb",
32
- "app/views/email_manager/managed_emails/_pagination.html.haml",
33
- "app/views/email_manager/managed_emails/_search_form.html.erb",
34
- "app/views/email_manager/managed_emails/_search_form.html.haml",
35
- "app/views/email_manager/managed_emails/index.html.erb",
36
- "app/views/email_manager/managed_emails/index.html.haml",
37
- "app/views/email_manager/managed_emails/show.html.erb",
38
- "app/views/email_manager/managed_emails/show.html.haml",
39
- "config/routes.rb",
40
- "email_manager.gemspec",
41
- "lib/email_manager.rb",
42
- "lib/email_manager/engine.rb",
43
- "lib/email_manager/managed_email_observer.rb",
44
- "lib/generators/email_manager/install_generator.rb",
45
- "lib/generators/email_manager/templates/email_manager_config.rb",
46
- "lib/generators/email_manager/templates/migrations/install.rb",
47
- "lib/generators/email_manager/upgrade_generator.rb",
48
- "lib/generators/email_manager/views_generator.rb",
49
- "reload.sh",
50
- "spec/controllers/managed_emails_controller_spec.rb",
51
- "spec/dummy/Rakefile",
52
- "spec/dummy/app/controllers/application_controller.rb",
53
- "spec/dummy/app/helpers/application_helper.rb",
54
- "spec/dummy/app/mailers/dummy_mailer.rb",
55
- "spec/dummy/app/views/dummy_mailer/dummy_email_notification.html.erb",
56
- "spec/dummy/app/views/layouts/application.html.erb",
57
- "spec/dummy/config.ru",
58
- "spec/dummy/config/application.rb",
59
- "spec/dummy/config/boot.rb",
60
- "spec/dummy/config/database.yml",
61
- "spec/dummy/config/environment.rb",
62
- "spec/dummy/config/environments/development.rb",
63
- "spec/dummy/config/environments/production.rb",
64
- "spec/dummy/config/environments/test.rb",
65
- "spec/dummy/config/initializers/backtrace_silencers.rb",
66
- "spec/dummy/config/initializers/email_manager_config.rb",
67
- "spec/dummy/config/initializers/inflections.rb",
68
- "spec/dummy/config/initializers/mime_types.rb",
69
- "spec/dummy/config/initializers/secret_token.rb",
70
- "spec/dummy/config/initializers/session_store.rb",
71
- "spec/dummy/config/locales/en.yml",
72
- "spec/dummy/config/routes.rb",
73
- "spec/dummy/db/migrate/20110706133041_install_email_manager.rb",
74
- "spec/dummy/db/test.sqlite3",
75
- "spec/dummy/log/server.log",
76
- "spec/dummy/public/404.html",
77
- "spec/dummy/public/422.html",
78
- "spec/dummy/public/500.html",
79
- "spec/dummy/public/favicon.ico",
80
- "spec/dummy/public/javascripts/application.js",
81
- "spec/dummy/public/javascripts/controls.js",
82
- "spec/dummy/public/javascripts/dragdrop.js",
83
- "spec/dummy/public/javascripts/effects.js",
84
- "spec/dummy/public/javascripts/prototype.js",
85
- "spec/dummy/public/javascripts/rails.js",
86
- "spec/dummy/public/stylesheets/.gitkeep",
87
- "spec/dummy/script/rails",
88
- "spec/email_manager_spec.rb",
89
- "spec/integration/navigation_spec.rb",
90
- "spec/managed_email_observer_spec.rb",
91
- "spec/models/managed_email_spec.rb",
92
- "spec/routing/managed_emails_spec.rb",
93
- "spec/spec_helper.rb"
94
- ]
95
- s.homepage = "https://github.com/jeremiahishere/email_manager"
96
- s.licenses = ["MIT"]
97
- s.require_paths = ["lib"]
98
- s.rubygems_version = "1.8.15"
99
- s.summary = "An email manager"
100
-
101
- if s.respond_to? :specification_version then
102
- s.specification_version = 3
103
-
104
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
105
- s.add_development_dependency(%q<rails>, [">= 3.0.0"])
106
- s.add_development_dependency(%q<sqlite3>, [">= 0"])
107
- s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
108
- s.add_development_dependency(%q<rspec-rails>, [">= 0"])
109
- s.add_development_dependency(%q<yard>, ["~> 0.6.0"])
110
- s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
111
- s.add_development_dependency(%q<ruby-debug19>, [">= 0"])
112
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
113
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.3"])
114
- s.add_development_dependency(%q<rcov>, [">= 0"])
115
- s.add_development_dependency(%q<cover_me>, [">= 1.0.0.rc6"])
116
- s.add_development_dependency(%q<ci_reporter>, [">= 0"])
117
- else
118
- s.add_dependency(%q<rails>, [">= 3.0.0"])
119
- s.add_dependency(%q<sqlite3>, [">= 0"])
120
- s.add_dependency(%q<rspec>, ["~> 2.6.0"])
121
- s.add_dependency(%q<rspec-rails>, [">= 0"])
122
- s.add_dependency(%q<yard>, ["~> 0.6.0"])
123
- s.add_dependency(%q<capybara>, [">= 0.4.0"])
124
- s.add_dependency(%q<ruby-debug19>, [">= 0"])
125
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
126
- s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
127
- s.add_dependency(%q<rcov>, [">= 0"])
128
- s.add_dependency(%q<cover_me>, [">= 1.0.0.rc6"])
129
- s.add_dependency(%q<ci_reporter>, [">= 0"])
130
- end
131
- else
132
- s.add_dependency(%q<rails>, [">= 3.0.0"])
133
- s.add_dependency(%q<sqlite3>, [">= 0"])
134
- s.add_dependency(%q<rspec>, ["~> 2.6.0"])
135
- s.add_dependency(%q<rspec-rails>, [">= 0"])
136
- s.add_dependency(%q<yard>, ["~> 0.6.0"])
137
- s.add_dependency(%q<capybara>, [">= 0.4.0"])
138
- s.add_dependency(%q<ruby-debug19>, [">= 0"])
139
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
140
- s.add_dependency(%q<jeweler>, ["~> 1.6.3"])
141
- s.add_dependency(%q<rcov>, [">= 0"])
142
- s.add_dependency(%q<cover_me>, [">= 1.0.0.rc6"])
143
- s.add_dependency(%q<ci_reporter>, [">= 0"])
144
- end
145
- end
146
-
data/reload.sh DELETED
@@ -1,2 +0,0 @@
1
- gem uninstall email_manager
2
- rake install
File without changes
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Navigation" do
4
- include Capybara::DSL
5
-
6
- it "should be a valid app" do
7
- ::Rails.application.should be_a(Dummy::Application)
8
- end
9
- end