cloudstrg 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. data/app/assets/javascripts/cloudstrg/configs.js +2 -0
  2. data/app/assets/javascripts/cloudstrg/remoteobjects.js +2 -0
  3. data/app/assets/stylesheets/cloudstrg/configs.css +4 -0
  4. data/app/assets/stylesheets/cloudstrg/remoteobjects.css +4 -0
  5. data/app/controllers/cloudstrg/configs_controller.rb +103 -0
  6. data/app/controllers/cloudstrg/configs_controller.rb~ +103 -0
  7. data/app/controllers/cloudstrg/remoteobjects_controller.rb +91 -0
  8. data/app/controllers/cloudstrg/remoteobjects_controller.rb~ +90 -0
  9. data/app/helpers/cloudstrg/configs_helper.rb +4 -0
  10. data/app/helpers/cloudstrg/remoteobjects_helper.rb +4 -0
  11. data/app/models/cloudstrg/cloudstrgplugin.rb +3 -0
  12. data/app/models/cloudstrg/cloudstrgplugin.rb~ +8 -0
  13. data/app/models/cloudstrg/config.rb +9 -0
  14. data/app/models/cloudstrg/config.rb~ +30 -0
  15. data/app/models/cloudstrg/remoteobject.rb +11 -0
  16. data/app/models/cloudstrg/remoteobject.rb~ +9 -0
  17. data/app/views/cloudstrg/configs/_form.html.erb +26 -0
  18. data/app/views/cloudstrg/configs/_form.html.erb~ +26 -0
  19. data/app/views/cloudstrg/configs/edit.html.erb +6 -0
  20. data/app/views/cloudstrg/configs/index.html.erb +29 -0
  21. data/app/views/cloudstrg/configs/index.html.erb~ +29 -0
  22. data/app/views/cloudstrg/configs/new.html.erb +5 -0
  23. data/app/views/cloudstrg/configs/show.html.erb +15 -0
  24. data/app/views/cloudstrg/configs/show.html.erb~ +15 -0
  25. data/app/views/cloudstrg/remoteobjects/_form.html.erb +33 -0
  26. data/app/views/cloudstrg/remoteobjects/edit.html.erb +6 -0
  27. data/app/views/cloudstrg/remoteobjects/index.html.erb +29 -0
  28. data/app/views/cloudstrg/remoteobjects/new.html.erb +5 -0
  29. data/app/views/cloudstrg/remoteobjects/show.html.erb +25 -0
  30. data/config/routes.rb +6 -0
  31. data/config/routes.rb~ +8 -0
  32. data/db/migrate/20121109112536_create_cloudstrg_remoteobjects.rb~ +12 -0
  33. data/db/migrate/20121109175154_create_cloudstrg_remoteobjects.rb +12 -0
  34. data/db/migrate/20121109175154_create_cloudstrg_remoteobjects.rb~ +12 -0
  35. data/db/migrate/20121113105908_create_cloudstrg_configs.rb +10 -0
  36. data/db/migrate/20121113105908_create_cloudstrg_configs.rb~ +10 -0
  37. data/db/migrate/20121116111055_rename_cloudstrg_config_plugin_id_to_cloudstrg_config_cloudstrgplugin_id.rb +5 -0
  38. data/db/migrate/20121119105425_rename_remoteobject_plugin_id_to_remoteobject_cloudstrgplugin_id.rb +5 -0
  39. data/db/migrate/20121119184135_add_file_remote_id_to_cloudstrg_remoteobjects.rb +5 -0
  40. data/db/migrate/20121119184135_add_file_remote_id_to_cloudstrg_remoteobjects.rb~ +5 -0
  41. data/db/migrate/20121120022309_change_file_remote_id_type_to_string.rb +6 -0
  42. data/lib/cloudstrg/cloudstrg.rb +44 -23
  43. data/lib/cloudstrg/cloudstrg.rb~ +164 -0
  44. data/lib/cloudstrg/version.rb +1 -1
  45. data/lib/cloudstrg.rb +1 -0
  46. data/test/dummy/db/development.sqlite3 +0 -0
  47. data/test/dummy/db/migrate/20121107132518_create_cloudstrg_cloudstrgplugins.cloudstrg.rb +11 -0
  48. data/test/dummy/db/schema.rb +23 -0
  49. data/test/dummy/log/development.log +16 -0
  50. data/test/fixtures/cloudstrg/configs.yml +9 -0
  51. data/test/fixtures/cloudstrg/remoteobjects.yml +13 -0
  52. data/test/functional/cloudstrg/configs_controller_test.rb +51 -0
  53. data/test/functional/cloudstrg/remoteobjects_controller_test.rb +51 -0
  54. data/test/unit/cloudstrg/config_test.rb +9 -0
  55. data/test/unit/cloudstrg/remoteobject_test.rb +9 -0
  56. data/test/unit/helpers/cloudstrg/configs_helper_test.rb +6 -0
  57. data/test/unit/helpers/cloudstrg/remoteobjects_helper_test.rb +6 -0
  58. metadata +64 -3
  59. data/lib/cloudstrg/version.rb~ +0 -3
@@ -0,0 +1,33 @@
1
+ <%= form_for(@remoteobject) do |f| %>
2
+ <% if @remoteobject.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@remoteobject.errors.count, "error") %> prohibited this remoteobject from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @remoteobject.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :user_id %><br />
16
+ <%= f.number_field :user_id %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :plugin_id %><br />
20
+ <%= f.number_field :plugin_id %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :filename %><br />
24
+ <%= f.text_field :filename %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :filehash %><br />
28
+ <%= f.text_field :filehash %>
29
+ </div>
30
+ <div class="actions">
31
+ <%= f.submit %>
32
+ </div>
33
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing remoteobject</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @remoteobject %> |
6
+ <%= link_to 'Back', remoteobjects_path %>
@@ -0,0 +1,29 @@
1
+ <h1>Listing remoteobjects</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>User</th>
6
+ <th>Plugin</th>
7
+ <th>Filename</th>
8
+ <th>Filehash</th>
9
+ <th></th>
10
+ <th></th>
11
+ <th></th>
12
+ </tr>
13
+
14
+ <% @remoteobjects.each do |remoteobject| %>
15
+ <tr>
16
+ <td><%= remoteobject.user_id %></td>
17
+ <td><%= remoteobject.plugin_id %></td>
18
+ <td><%= remoteobject.filename %></td>
19
+ <td><%= remoteobject.filehash %></td>
20
+ <td><%= link_to 'Show', remoteobject %></td>
21
+ <td><%= link_to 'Edit', edit_remoteobject_path(remoteobject) %></td>
22
+ <td><%= link_to 'Destroy', remoteobject, method: :delete, data: { confirm: 'Are you sure?' } %></td>
23
+ </tr>
24
+ <% end %>
25
+ </table>
26
+
27
+ <br />
28
+
29
+ <%= link_to 'New Remoteobject', new_remoteobject_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New remoteobject</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', remoteobjects_path %>
@@ -0,0 +1,25 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>User:</b>
5
+ <%= @remoteobject.user_id %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Plugin:</b>
10
+ <%= @remoteobject.plugin_id %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Filename:</b>
15
+ <%= @remoteobject.filename %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Filehash:</b>
20
+ <%= @remoteobject.filehash %>
21
+ </p>
22
+
23
+
24
+ <%= link_to 'Edit', edit_remoteobject_path(@remoteobject) %> |
25
+ <%= link_to 'Back', remoteobjects_path %>
data/config/routes.rb CHANGED
@@ -1,4 +1,10 @@
1
1
  Cloudstrg::Engine.routes.draw do
2
+ resources :configs
3
+
4
+ resources :remoteobjects
5
+
2
6
  resources :cloudstrgplugins
3
7
 
8
+ get '/cloudstrgplugins/:plugin_id/files(.:format)' => 'remoteobjects#index'
9
+
4
10
  end
data/config/routes.rb~ ADDED
@@ -0,0 +1,8 @@
1
+ Cloudstrg::Engine.routes.draw do
2
+ resources :remoteobjects
3
+
4
+ resources :cloudstrgplugins
5
+
6
+ get '/cloudstrgplugins/:plugin_id/files(.:format)' => 'remoteobjects#index'
7
+
8
+ end
@@ -0,0 +1,12 @@
1
+ class CreateCloudstrgRemoteobjects < ActiveRecord::Migration
2
+ def change
3
+ create_table :cloudstrg_remoteobjects do |t|
4
+ t.integer :user_id
5
+ t.integer :plugin_id
6
+ t.string :filename
7
+ t.fixnum :filehash
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateCloudstrgRemoteobjects < ActiveRecord::Migration
2
+ def change
3
+ create_table :cloudstrg_remoteobjects do |t|
4
+ t.integer "#{Cloudstrg.user_class.downcase}_id".to_sym
5
+ t.integer :plugin_id
6
+ t.string :filename
7
+ t.string :filehash
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateCloudstrgRemoteobjects < ActiveRecord::Migration
2
+ def change
3
+ create_table :cloudstrg_remoteobjects do |t|
4
+ t.integer "#{Cloudstrg.user_class}_id".to_sym
5
+ t.integer :plugin_id
6
+ t.string :filename
7
+ t.string :filehash
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,10 @@
1
+ class CreateCloudstrgConfigs < ActiveRecord::Migration
2
+ def change
3
+ create_table :cloudstrg_configs do |t|
4
+ t.integer "#{Cloudstrg.user_class.downcase}_id".to_sym
5
+ t.integer :plugin_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateCloudstrgConfigs < ActiveRecord::Migration
2
+ def change
3
+ create_table :cloudstrg_configs do |t|
4
+ t.integer "#{Cloudstrg.user_class}_id".to_sym
5
+ t.integer :plugin_id
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class RenameCloudstrgConfigPluginIdToCloudstrgConfigCloudstrgpluginId < ActiveRecord::Migration
2
+ def change
3
+ rename_column :cloudstrg_configs, :plugin_id, :cloudstrgplugin_id
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RenameCloudstrgRemoteobjectPluginIdToCloudstrgRemoteobjectCloudstrgpluginId < ActiveRecord::Migration
2
+ def change
3
+ rename_column :cloudstrg_remoteobjects, :plugin_id, :cloudstrgplugin_id
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddFileRemoteIdToCloudstrgRemoteobjects < ActiveRecord::Migration
2
+ def change
3
+ add_column :cloudstrg_remoteobjects, :file_remote_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddFileRemoteIdToCloudstrgRemoteobjects < ActiveRecord::Migration
2
+ def change
3
+ add_column :cloudstrg_remoteobjects, :file_remote_id, :string
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class ChangeFileRemoteIdTypeToString < ActiveRecord::Migration
2
+ def change
3
+ change_column :cloudstrg_remoteobjects, :file_remote_id, :string
4
+
5
+ end
6
+ end
@@ -4,13 +4,13 @@ module CloudStrg
4
4
  # This method returns an instance of an specified driver
5
5
  #
6
6
  # Params: the "params" variable must contain the following fields
7
- # type: the name of the selected driver.
7
+ # plugin_id: the id of the selected driver.
8
8
  #
9
9
  # Returns:
10
10
  # An instance of the specified driver.
11
11
  #
12
12
  def self.new_driver params
13
- type = params[:type]
13
+ type = Cloudstrg::Cloudstrgplugin.find(params[:plugin_id]).plugin_name
14
14
  require "#{type}strg/#{type}strg"
15
15
  return Kernel.const_get("#{type.capitalize}Strg").new(params)
16
16
  end
@@ -20,7 +20,8 @@ module CloudStrg
20
20
  # This method returns a list of the available storage drivers.
21
21
  #
22
22
  def self.driver_list
23
- l = Cloudstrg::Cloudstrgplugin.select('plugin_name')
23
+ l = []
24
+ Cloudstrg::Cloudstrgplugin.find(:all).each {|plugin| l << [plugin.plugin_name, plugin.id]}
24
25
  l.sort!
25
26
  return l
26
27
  end
@@ -35,9 +36,9 @@ module CloudStrg
35
36
  # This method performs the previous configuration that the current driver needs to work.
36
37
  #
37
38
  # Params: the "params" variable must contain the following fields
38
- # redirect: the name of the selected driver,
39
- # username: the name of the selected driver,
40
- # session: the name of the selected driver.
39
+ # redirect: url that we want the application to redirect us before accepting the selected cloud engine terms,
40
+ # user: the current user,
41
+ # session: the session hash.
41
42
  #
42
43
  # Returns:
43
44
  # This method returns two parameters:
@@ -57,7 +58,7 @@ module CloudStrg
57
58
  # file_content: the content of the file.
58
59
  #
59
60
  # Returns:
60
- # This method returns true if the operation success, otherwise it returns false.
61
+ # This method returns the local id of the remote object if the operation success, otherwise it returns false.
61
62
  #
62
63
  def create_file params
63
64
  raise NotImplementedError
@@ -92,7 +93,7 @@ module CloudStrg
92
93
  # file_content: the content of the file.
93
94
  #
94
95
  # Returns:
95
- # This method returns true if the operation success, otherwise it returns false.
96
+ # This method returns the local id of the remote object if the operation success, otherwise it returns false.
96
97
  #
97
98
  def update_file params
98
99
  raise NotImplementedError
@@ -118,26 +119,46 @@ module CloudStrg
118
119
  raise NotImplementedError
119
120
  end
120
121
 
121
- def save_hash(username, filename, filecontent)
122
- plugin_name = self.class.to_s.split('Strg')[0].downcase
122
+ def save_remoteobject(user, filename, filecontent, file_remote_id)
123
+ #plugin_name = self.class.to_s.split('Strg')[0].downcase
123
124
 
124
- if Cloudstrgfile.where(:username => username, :strgdriver => plugin_name, :filename => filename).size > 0
125
- Cloudstrgfile.delete_all(:username => username, :strgdriver => plugin_name, :filename => filename)
125
+ file = Cloudstrg::Remoteobject.where(:user_id => user, :cloudstrgplugin_id => user.cloudstrgconfig.cloudstrgplugin, :filename => filename)
126
+ if not file.empty?
127
+ file = file[0]
128
+ file.filehash = filecontent.hash.to_s
129
+ else
130
+ file = user.cloudstrgconfig.cloudstrgplugin.remoteobjects.build(:user_id => user, :filename => filename, :filehash => filecontent.hash.to_s, :file_remote_id => file_remote_id)
126
131
  end
127
- Cloudstrgfile.create :username => username, :filename => filename, :filehash => filecontent.hash.to_s, :strgdriver => plugin_name
128
- true
132
+ file.save
133
+ return file
129
134
  end
130
135
 
131
- def check_hash(username, filename, filecontent)
132
- plugin_name = self.class.to_s.split('Strg')[0].downcase
133
-
134
- l = Cloudstrgfile.where(:username => username, :strgdriver => plugin_name, :filename => filename)
135
- if l.size != 1
136
- return l[0].filehash == filecontent.hash.to_s
137
- else
138
- false
139
- end
136
+ def get_remoteobject(ro_id)
137
+ return Cloudstrg::Remoteobject.find(ro_id)
138
+ end
139
+
140
+ def delete_remoteobject(ro_id)
141
+ return Cloudstrg::Remoteobject.find(ro_id).destroy
140
142
  end
141
143
 
144
+ # def check_hash(username, filename, filecontent)
145
+ # plugin_name = self.class.to_s.split('Strg')[0].downcase
146
+ #
147
+ # l = Cloudstrg::Remoteobject.where(:username => username, :strgdriver => plugin_name, :filename => filename)
148
+ # if l.size == 1
149
+ # return l[0].filehash == filecontent.hash.to_s
150
+ # else
151
+ # false
152
+ # end
153
+ # end
154
+
142
155
  end
156
+
157
+ class RONotConfigured < Exception
158
+ end
159
+
160
+ class ROValidationRequired < Exception
161
+ end
162
+
163
+
143
164
  end
@@ -0,0 +1,164 @@
1
+ module CloudStrg
2
+
3
+ ##
4
+ # This method returns an instance of an specified driver
5
+ #
6
+ # Params: the "params" variable must contain the following fields
7
+ # plugin_id: the id of the selected driver.
8
+ #
9
+ # Returns:
10
+ # An instance of the specified driver.
11
+ #
12
+ def self.new_driver params
13
+ type = Cloudstrg::Cloudstrgplugin.find(params[:plugin_id]).plugin_name
14
+ require "#{type}strg/#{type}strg"
15
+ return Kernel.const_get("#{type.capitalize}Strg").new(params)
16
+ end
17
+
18
+
19
+ ##
20
+ # This method returns a list of the available storage drivers.
21
+ #
22
+ def self.driver_list
23
+ l = []
24
+ Cloudstrg::Cloudstrgplugin.find(:all).each {|plugin| l << [plugin.plugin_name, plugin.id]}
25
+ l.sort!
26
+ return l
27
+ end
28
+
29
+ ###
30
+ # This class must be inherited by every single driver definition in order to preserve
31
+ # the coherence between them.
32
+ #
33
+ class CloudStorage
34
+
35
+ ###
36
+ # This method performs the previous configuration that the current driver needs to work.
37
+ #
38
+ # Params: the "params" variable must contain the following fields
39
+ # redirect: url that we want the application to redirect us before accepting the selected cloud engine terms,
40
+ # user: the current user,
41
+ # session: the session hash.
42
+ #
43
+ # Returns:
44
+ # This method returns two parameters:
45
+ # session: the session variable with the new parameters added,
46
+ # uri: the uri where the user will allow the application to use the desired service,
47
+ # or false if the configuration was completed successfully.
48
+ #
49
+ def config params
50
+ raise NotImplementedError
51
+ end
52
+
53
+ ###
54
+ # This method performs the creation of a file.
55
+ #
56
+ # Params: the "params" variable must contain the following fields
57
+ # filename: the name of the file to create,
58
+ # file_content: the content of the file.
59
+ #
60
+ # Returns:
61
+ # This method returns the local id of the remote object if the operation success, otherwise it returns false.
62
+ #
63
+ def create_file params
64
+ raise NotImplementedError
65
+ end
66
+
67
+ #def create_folder params
68
+ # raise NotImplementedError
69
+ #end
70
+
71
+ ###
72
+ # This method performs the request to obtain a desired file content
73
+ #
74
+ # Params: the "params" variable must contain the following fields
75
+ # fileid: the id of the selected file.
76
+ #
77
+ # Returns:
78
+ # This method returns three parameters:
79
+ # filename: the name of the file,
80
+ # fileid: the id of the file,
81
+ # file_content: the content of the file.
82
+ #
83
+ def get_file params
84
+ raise NotImplementedError
85
+ end
86
+
87
+ ###
88
+ # This method performs the update of a file.
89
+ #
90
+ # Params: the "params" variable must contain the following fields
91
+ # filename: the name of the file to edit,
92
+ # fileid: the id of the file,
93
+ # file_content: the content of the file.
94
+ #
95
+ # Returns:
96
+ # This method returns the local id of the remote object if the operation success, otherwise it returns false.
97
+ #
98
+ def update_file params
99
+ raise NotImplementedError
100
+ end
101
+
102
+ ###
103
+ # This method performs the remove of a file.
104
+ #
105
+ # Params: the "params" variable must contain the following fields
106
+ # fileid: the id of the file.
107
+ #
108
+ def remove_file params
109
+ raise NotImplementedError
110
+ end
111
+
112
+ ###
113
+ # This method returns a list of the available files created by the application.
114
+ #
115
+ # Returns:
116
+ # This method returns a list of tuples, containing: [[filename, fileid], ...]
117
+ #
118
+ def list_files
119
+ raise NotImplementedError
120
+ end
121
+
122
+ def save_remoteobject(user, filename, filecontent, file_remote_id)
123
+ #plugin_name = self.class.to_s.split('Strg')[0].downcase
124
+
125
+ file = Cloudstrg::Remoteobject.where(:user_id => user, :cloudstrgplugin_id => user.cloudstrgconfig.cloudstrgplugin, :filename => filename)
126
+ if not file.empty?
127
+ file = file[0]
128
+ file.filehash = filecontent.hash.to_s
129
+ else
130
+ file = user.cloudstrgconfig.cloudstrgplugin.remoteobjects.build(:user_id => user, :filename => filename, :filehash => filecontent.hash.to_s, :file_remote_id => file_remote_id)
131
+ end
132
+ file.save
133
+ return file
134
+ end
135
+
136
+ def get_remoteobject(ro_id)
137
+ return Cloudstrg::Remoteobject.find(ro_id)
138
+ end
139
+
140
+ def delete_remoteobject(ro_id)
141
+ return Cloudstrg::Remoteobject.find(ro_id).destroy
142
+ end
143
+
144
+ # def check_hash(username, filename, filecontent)
145
+ # plugin_name = self.class.to_s.split('Strg')[0].downcase
146
+ #
147
+ # l = Cloudstrg::Remoteobject.where(:username => username, :strgdriver => plugin_name, :filename => filename)
148
+ # if l.size == 1
149
+ # return l[0].filehash == filecontent.hash.to_s
150
+ # else
151
+ # false
152
+ # end
153
+ # end
154
+
155
+ end
156
+
157
+ class RONotConfigured < Exception
158
+ end
159
+
160
+ class ROValidationRequired < Exception
161
+ end
162
+
163
+
164
+ end
@@ -1,3 +1,3 @@
1
1
  module Cloudstrg
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/cloudstrg.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "cloudstrg/engine"
2
2
 
3
3
  module Cloudstrg
4
+ mattr_accessor :user_class
4
5
  end
Binary file
@@ -0,0 +1,11 @@
1
+ # This migration comes from cloudstrg (originally 20121105173015)
2
+ class CreateCloudstrgCloudstrgplugins < ActiveRecord::Migration
3
+ def change
4
+ create_table :cloudstrg_cloudstrgplugins do |t|
5
+ t.string :plugin_name
6
+ t.string :version
7
+
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
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 => 20121107132518) do
15
+
16
+ create_table "cloudstrg_cloudstrgplugins", :force => true do |t|
17
+ t.string "plugin_name"
18
+ t.string "version"
19
+ t.datetime "created_at", :null => false
20
+ t.datetime "updated_at", :null => false
21
+ end
22
+
23
+ end
@@ -1,3 +1,19 @@
1
1
  Connecting to database specified by database.yml
2
2
  Connecting to database specified by database.yml
3
3
  Connecting to database specified by database.yml
4
+ Connecting to database specified by database.yml
5
+ Connecting to database specified by database.yml
6
+  (0.2ms) select sqlite_version(*)
7
+  (139.8ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL)
8
+  (0.1ms) PRAGMA index_list("schema_migrations")
9
+  (101.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
10
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
11
+ Migrating to CreateCloudstrgCloudstrgplugins (20121107132518)
12
+  (0.1ms) begin transaction
13
+  (1.1ms) CREATE TABLE "cloudstrg_cloudstrgplugins" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "plugin_name" varchar(255), "version" varchar(255), "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
14
+  (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ('20121107132518')
15
+  (132.9ms) commit transaction
16
+  (0.7ms) select sqlite_version(*)
17
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
18
+  (0.1ms) PRAGMA index_list("cloudstrg_cloudstrgplugins")
19
+ Connecting to database specified by database.yml
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ user_id: 1
5
+ plugin_id: 1
6
+
7
+ two:
8
+ user_id: 1
9
+ plugin_id: 1
@@ -0,0 +1,13 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ user_id: 1
5
+ plugin_id: 1
6
+ filename: MyString
7
+ filehash: MyString
8
+
9
+ two:
10
+ user_id: 1
11
+ plugin_id: 1
12
+ filename: MyString
13
+ filehash: MyString
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module Cloudstrg
4
+ class ConfigsControllerTest < ActionController::TestCase
5
+ setup do
6
+ @config = configs(:one)
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:configs)
13
+ end
14
+
15
+ test "should get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create config" do
21
+ assert_difference('Config.count') do
22
+ post :create, config: { plugin_id: @config.plugin_id, user_id: @config.user_id }
23
+ end
24
+
25
+ assert_redirected_to config_path(assigns(:config))
26
+ end
27
+
28
+ test "should show config" do
29
+ get :show, id: @config
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ get :edit, id: @config
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update config" do
39
+ put :update, id: @config, config: { plugin_id: @config.plugin_id, user_id: @config.user_id }
40
+ assert_redirected_to config_path(assigns(:config))
41
+ end
42
+
43
+ test "should destroy config" do
44
+ assert_difference('Config.count', -1) do
45
+ delete :destroy, id: @config
46
+ end
47
+
48
+ assert_redirected_to configs_path
49
+ end
50
+ end
51
+ end