fine_print 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5872d7ae6a8abfb926c3eb5c3203e086937ee70c
4
- data.tar.gz: c685f59d91186586a78bd74eafaf16e2c02c2b65
3
+ metadata.gz: 737d9043df423544d60771c30e22ef71811bcb4b
4
+ data.tar.gz: 6e54249ed44c5178b6fe8ea17d6518680cf5436b
5
5
  SHA512:
6
- metadata.gz: 96ee62c1e276077980ff95575e896ada2e679d9663a4bd84c55208434e86c37452b84ed1b83142b6051b07a217d520cc5ab336810c9e0dcbe1b93bdc20699e23
7
- data.tar.gz: b4da61298157efa7fb336d8b88b8a4c2011b6373995b27e67d7cbff1bcaeaa5dfc6571095d7020d65ea95226d47ef0f4aa4be4b15609f685ef6d4c75728d87e9
6
+ metadata.gz: 268d93027f2008ebadafed4b5dd735235b3506fa0bb7813af8be63dc727e3178ae25c09c885d92d03b7290bc9298bbb4e62116998db17c0d4df76c0cc1f716ef
7
+ data.tar.gz: 3f1c3ccdf8fcdb31522c61cf524c5b979f566ad80d75a0c4d703c4ae3a6889bafc79084613533e256388ad110739a2902f0de34236527ce25b079d22ba5b3d25
@@ -1,3 +1,3 @@
1
1
  module FinePrint
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module FinePrint
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
data/lib/fine_print.rb CHANGED
@@ -38,8 +38,8 @@ module FinePrint
38
38
  ref
39
39
  when Integer
40
40
  Contract.find(ref)
41
- when String
42
- Contract.where(:name => ref).published.first
41
+ when String, Symbol
42
+ Contract.where(:name => ref.to_s).published.first
43
43
  end
44
44
  end
45
45
 
data/lib/fine_print.rb~ CHANGED
@@ -39,7 +39,7 @@ module FinePrint
39
39
  when Integer
40
40
  Contract.find(ref)
41
41
  when String
42
- Contract.where(:name => ref).published.first
42
+ Contract.where(:name => ref.to_s).published.first
43
43
  end
44
44
  end
45
45
 
@@ -82,6 +82,26 @@ module FinePrint
82
82
  :user_id => user.id).first.nil?
83
83
  end
84
84
 
85
+ # Returns an array of names for the contracts whose latest published
86
+ # version the given user has not signed.
87
+ # - user -- the user in question
88
+ # - names -- contract names to check
89
+ #
90
+ def self.get_unsigned_contract_names(user, *names)
91
+ raise_unless_signed_in(user)
92
+ names = names.flatten.collect{|name| name.to_s}
93
+ return [] if names.blank?
94
+
95
+ signed_contracts = Contract
96
+ .joins(:signatures)
97
+ .where({:name => names,
98
+ :fine_print_signatures => {:user_id => user.id,
99
+ :user_type => user.class.name}}).latest
100
+ signed_contract_names = signed_contracts.collect{|c| c.name}
101
+
102
+ return names - signed_contract_names
103
+ end
104
+
85
105
  def self.is_signed_in?(user)
86
106
  user_signed_in_proc.call(user)
87
107
  end
Binary file
@@ -1745,3 +1745,29 @@ Connecting to database specified by database.yml
1745
1745
   (4.4ms) CREATE INDEX "index_fine_print_signatures_on_contract_id" ON "fine_print_signatures" ("contract_id")
1746
1746
   (4.5ms) CREATE UNIQUE INDEX "index_fine_print_s_on_u_id_and_u_type_and_c_id" ON "fine_print_signatures" ("user_id", "user_type", "contract_id")
1747
1747
   (0.1ms) SELECT version FROM "schema_migrations"
1748
+ Connecting to database specified by database.yml
1749
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
1750
+  (0.1ms) select sqlite_version(*)
1751
+  (59.6ms) DROP TABLE "dummy_users"
1752
+  (5.0ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "is_admin" boolean DEFAULT 'f' NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1753
+  (5.1ms) DROP TABLE "fine_print_contracts"
1754
+  (4.5ms) CREATE TABLE "fine_print_contracts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "version" integer, "title" varchar(255) NOT NULL, "content" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1755
+  (6.2ms) CREATE UNIQUE INDEX "index_fine_print_contracts_on_name_and_version" ON "fine_print_contracts" ("name", "version")
1756
+  (4.9ms) DROP TABLE "fine_print_signatures"
1757
+  (4.8ms) CREATE TABLE "fine_print_signatures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "contract_id" integer NOT NULL, "user_id" integer NOT NULL, "user_type" varchar(255) NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
1758
+  (4.3ms) CREATE INDEX "index_fine_print_signatures_on_contract_id" ON "fine_print_signatures" ("contract_id")
1759
+  (4.6ms) CREATE UNIQUE INDEX "index_fine_print_s_on_u_id_and_u_type_and_c_id" ON "fine_print_signatures" ("user_id", "user_type", "contract_id")
1760
+  (0.1ms) SELECT version FROM "schema_migrations"
1761
+ Connecting to database specified by database.yml
1762
+  (0.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" 
1763
+  (0.2ms) select sqlite_version(*)
1764
+  (20.7ms) DROP TABLE "dummy_users"
1765
+  (4.3ms) CREATE TABLE "dummy_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "is_admin" boolean DEFAULT 'f' NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1766
+  (4.4ms) DROP TABLE "fine_print_contracts"
1767
+  (4.3ms) CREATE TABLE "fine_print_contracts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) NOT NULL, "version" integer, "title" varchar(255) NOT NULL, "content" text NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
1768
+  (4.6ms) CREATE UNIQUE INDEX "index_fine_print_contracts_on_name_and_version" ON "fine_print_contracts" ("name", "version")
1769
+  (4.6ms) DROP TABLE "fine_print_signatures"
1770
+  (4.4ms) CREATE TABLE "fine_print_signatures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "contract_id" integer NOT NULL, "user_id" integer NOT NULL, "user_type" varchar(255) NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
1771
+  (4.2ms) CREATE INDEX "index_fine_print_signatures_on_contract_id" ON "fine_print_signatures" ("contract_id")
1772
+  (4.2ms) CREATE UNIQUE INDEX "index_fine_print_s_on_u_id_and_u_type_and_c_id" ON "fine_print_signatures" ("user_id", "user_type", "contract_id")
1773
+  (0.1ms) SELECT version FROM "schema_migrations"