limesurvey-rails 0.0.1 → 0.0.2

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.
@@ -9,6 +9,10 @@ module LimesurveyRails
9
9
  configuration.api_base_url && configuration.api_base_url + "/admin/remotecontrol"
10
10
  end
11
11
 
12
+ def self.new_survey_url
13
+ configuration.api_base_url + '/admin/survey/sa/newsurvey'
14
+ end
15
+
12
16
  def self.connect
13
17
  if connected?
14
18
  false
@@ -9,9 +9,6 @@ module LimesurveyRails
9
9
 
10
10
  alias_attribute :id, :sid
11
11
 
12
- validates_presence_of :surveyls_title, :surveyls_language
13
- validate :surveyls_title_must_be_unique
14
-
15
12
  def self.all
16
13
  LimesurveyRails.list_surveys.map do |s|
17
14
  attributes = LimesurveyRails.get_survey_properties(s['sid'],ATTRIBUTES)
@@ -20,16 +17,13 @@ module LimesurveyRails
20
17
  end
21
18
 
22
19
  def self.find(sid)
23
- LimesurveyRails.get_survey_properties(sid,ATTRIBUTES)
20
+ attributes = LimesurveyRails.get_survey_properties(sid,ATTRIBUTES)
21
+ new(attributes)
24
22
  end
25
23
 
26
- # def self.new_url
27
- # LIMESURVEY_API_BASE_URL + '/admin/survey/sa/newsurvey'
28
- # end
29
-
30
- # def url
31
- # LIMESURVEY_API_BASE_URL + "/admin/survey/sa/view/surveyid/#{surveyls_survey_id}"
32
- # end
24
+ def url
25
+ LimesurveyRails.configuration.api_base_url + "/admin/survey/sa/view/surveyid/#{sid}"
26
+ end
33
27
 
34
28
  # def lang
35
29
  # surveyls_language
@@ -42,11 +36,6 @@ module LimesurveyRails
42
36
 
43
37
  # private
44
38
 
45
- # def surveyls_title_must_be_unique
46
- # if LIMESURVEY_API.list_surveys(LS_SESSION_KEY).map{|s| s['surveyls_title']}.include?(surveyls_title)
47
- # errors.add(:surveyls_title, "already present on Limesurvey")
48
- # end
49
- # end
50
39
  end
51
40
 
52
41
  end
@@ -2,7 +2,7 @@ class LimesurveyRails
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 2
6
6
  BUILD = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "limesurvey-rails"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["masciugo"]
@@ -75,6 +75,9 @@ describe LimesurveyRails do
75
75
  describe ".wrong_name_method" do
76
76
  specify { expect { LimesurveyRails.wrong_name_method }.to raise_error }
77
77
  end
78
+ describe ".new_survey_url" do
79
+ specify { expect(LimesurveyRails.new_survey_url).to eq(LIMESURVEY_API_BASE_URL + '/admin/survey/sa/newsurvey') }
80
+ end
78
81
  end
79
82
  end
80
83
 
@@ -1,3 +1,4 @@
1
1
  LIMESURVEY_USERNAME = "rails_user"
2
2
  LIMESURVEY_PASSWORD = "limoncello"
3
3
  LIMESURVEY_API_BASE_URL = "http://172.21.42.5/~cinzia/limesurvey/index.php"
4
+ LIMESURVEY_TEST_SURVEY_ID = '312863'
data/spec/survey_spec.rb CHANGED
@@ -19,10 +19,20 @@ describe LimesurveyRails::Survey, :wip => true do
19
19
  end
20
20
  end
21
21
 
22
- describe ".find(642564)" do
23
- it "return a Hash" do
24
- LimesurveyRails::Survey.find(642564).should be_an_instance_of(Hash)
22
+ describe ".find(LIMESURVEY_TEST_SURVEY_ID)" do
23
+ it "return a Survey object" do
24
+ LimesurveyRails::Survey.find(LIMESURVEY_TEST_SURVEY_ID).should be_an_instance_of(LimesurveyRails::Survey)
25
25
  end
26
26
  end
27
-
27
+
28
+ describe "#url" do
29
+ it "return the limesurvey survey url" do
30
+ s = LimesurveyRails::Survey.find(LIMESURVEY_TEST_SURVEY_ID)
31
+ expect(s.url).to eq(LIMESURVEY_API_BASE_URL + "/admin/survey/sa/view/surveyid/#{LIMESURVEY_TEST_SURVEY_ID}")
32
+ end
33
+ end
34
+
35
+ describe "#destroy" do
36
+
37
+ end
28
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: limesurvey-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -183,7 +183,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  segments:
185
185
  - 0
186
- hash: -2411240419226384970
186
+ hash: -2575607421667467541
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  none: false
189
189
  requirements: